Later in the war, Skywalker saved his life in a battle fought over Coruscant, after which Kenobi killed General Grievous on Utapau.
However, he was soon betrayed, as Commander Cody, following Order 66, opened fire on him.
The glare caused Obi-Wan's features to blur and dissolve. He saw an elder man, alone, living on a desolate planet, his only companions his dark memories. Visions did not have to come true..." In reality, Kenobi would later conclude that these memories were visions from the Force of Owen Lars.
Qui-Gon felt the same shiver he'd experienced in O-Vieve's presence ... The fraternity he felt between himself and Owen was true, from a certain point of view.
In a duel with his former apprentice, Kenobi gave up his life to allow Luke to escape, vanishing into the Force the moment Vader struck him down with his weapon.
Three years later, his spirit returned to Luke to lead him to Dagobah in order to learn from Master Yoda.
The two returned to the Jedi Temple, where they learned the agonizing truth: Skywalker, now lost to the dark side of the Force, had led an attack to kill all Jedi remaining in the Jedi Temple, following orders from Chancellor Palpatine, the ruler of the successor of the Republic, the Galactic Empire.
While Yoda, one of the few other Jedi to survive the Great Jedi Purge, went into exile, Kenobi took the son of Skywalker and Amidala, Luke Skywalker, to live with the Lars family on Tatooine.
He became a friend of the young Skywalker as he grew up, but he did not tell Skywalker his actual identity.
Kenobi traveled to Mustafar in order to duel his former apprentice and friend, now the Sith Lord Darth Vader.
Finally, Vader was taken in by a storm of lava, and Kenobi remorsefully left him to die.