The Empire Strikes Back
Yoda makes his first film appearance in The Empire Strikes Back (1980). Luke Skywalker arrives on Dagobah to seek his guidance, having been instructed to do so by the Force ghost of Obi-Wan Kenobi.
Rather than immediately identifying himself, Yoda tests Luke by initially presenting himself as a comical, backwater individual, deliberately provoking both Luke and R2-D2 (portrayed by Kenny Baker). Finding that Luke exhibits many of the flaws that led to his father's downfall, Yoda is reluctant to teach him in the ways of the Force, but agrees to do so at the spectral Obi-Wan's behest. Before finishing his training, however, Luke chooses to leave Dagobah in order to confront Darth Vader (played by David Prowse/voiced by James Earl Jones) and save his friends from the Empire's grasp at Bespin. Yoda and Obi-Wan insist to Luke that he is being lured into a trap, and that he must stay to complete his training. Luke refuses to forsake his friends, but gives Yoda his promise to return. As Luke departs, Obi-Wan laments that the boy is their "last hope," but Yoda reminds him that "there is another."
Return of the Jedi
Yoda's final chronological appearance is in Star Wars Episode VI: Return of the Jedi, set a year after The Empire Strikes Back. Yoda, sick and greatly weakened by old age, informs Luke that he has completed his training but will not be a Jedi until he confronts Darth Vader; he also confirms that Vader is Luke's father, which the Sith Lord had told a shocked Luke in the previous film. Yoda then peacefully dies at the age of 900, his body disappearing as he becomes "one with the Force". He leaves Luke with the knowledge that "there is another Skywalker." Moments later, Obi-Wan's ghost helps Luke come to the realization that the "other" whom Yoda spoke of is Princess Leia (Carrie Fisher), who is his twin sister.
In the film's final scene, after the Empire has been defeated, Luke sees Yoda's spirit looking upon him with pride, alongside Obi-Wan and the redeemed Anakin Skywalker (Vader's former Jedi self).
The Phantom Menace
In the films' timeline, Yoda first appears in Star Wars Episode I: The Phantom Menace, which is set 35 years before Empire Strikes Back. Qui-Gon Jinn (Liam Neeson) brings the young Anakin Skywalker (Jake Lloyd) to the Jedi Council. Qui-Gon claims that the boy is the "Chosen One" who will bring balance to the Force, and requests to train him once Obi-Wan (Ewan McGregor) has completed the trials necessary to become a Jedi Knight. Yoda senses great fear in the boy, and tells him, "Fear is the path to the dark side. Fear leads to anger. Anger leads to hate. Hate leads to suffering." Yoda plays a key role in the Council's initial decision to deny the request; he believes that Anakin is clearly affected by his years as a slave, and that he still clings too tightly to the memory of his mother to be trained safely.
Qui-Gon's dying wish after being mortally wounded in a duel with Sith Lord Darth Maul is that Obi-Wan train Anakin as a Jedi. During a subsequent discussion with Yoda, Obi-Wan insists on training Anakin, with or without the Jedi Council's permission. Yoda reluctantly rescinds his previous decision and permits Obi-Wan to train Anakin.
Attack of the Clones
In Star Wars Episode II: Attack of the Clones, set 10 years after The Phantom Menace, Yoda is one of the many Jedi who are concerned about the emergence of the Separatists, a group of systems rebelling against the Galactic Republic. After the second attempted assassination of Senator Padmé Amidala, Chancellor Palpatine "suggests" that she be put under the protection of Obi-Wan, who is training Anakin Skywalker.
Yoda later leads an army of Jedi and clone troopers in the film's climactic battle scene. He helps rescue Obi-Wan, Anakin and Padmé from execution at the hands of the Separatists. At the climax of the battle, Yoda duels with Separatist leader and Sith Lord Count Dooku, his former Jedi apprentice. Although seemingly frail, the ancient Yoda demonstrates agility and mastery of lightsaber combat and acrobatics through the Force. This confrontation ends with Dooku making his escape by threatening Yoda's comrades, Anakin and Obi-Wan.
Revenge of the Sith
In Star Wars Episode III: Revenge of the Sith, set three years after Attack of the Clones, Yoda leads the Jedi Council in pursuing the mysterious Sith Lord Darth Sidious. Palpatine has by now amassed near-dictatorial emergency powers, and begins interfering in Jedi affairs by appointing Anakin as his personal representative on the Council. The Council grants Anakin a Council seat, but denies him the rank of Master, feeling that doing so would amount to giving Palpatine a vote in the Council. Embittered by the perceived snub, Anakin begins to lose faith in the Jedi.
Anakin seeks Yoda's counsel about his prophetic visions that someone close to him will die. Yoda, unaware of the intensity of Anakin's love for Padmé, his pregnant wife, tells him to "Train yourself to let go of everything you fear to lose." Unsatisfied, Anakin turns to Palpatine, who reveals himself as Darth Sidious, and manipulates the young Jedi into becoming his Sith apprentice—Darth Vader—with the promise that the dark side holds the power to save Padmé from dying in childbirth.
Palpatine later transforms the Republic into the tyrannical Galactic Empire, proclaiming himself Emperor for life, and orders the clone troopers to kill their Jedi generals. At this time, Yoda is on Kashyyyk, overseeing the battle between the Separatist forces and a combined command of clone troopers and Wookiees. Through the Force, he feels the deaths of each of the Jedi as they are assassinated by their own troops. After swiftly killing the clone troopers instructed to kill him, he escapes with the help of Wookiee leaders Tarfful and Chewbacca, and returns to Coruscant, where he and Obi-Wan fight their way into the Jedi Temple to stop a trap for any surviving Jedi. Inside, they discover that all the Jedi inside, younglings included, have been slaughtered. They then discover a holographic recording revealing Anakin as the assassin. Yoda decides to face Palpatine, sending Obi-Wan to kill his former Padawan. Obi-Wan tells Yoda he cannot kill Anakin, asking instead to go after Palpatine. However, Yoda insists, saying, "To fight this Lord Sidious, strong enough you are not." He also tells Obi-Wan that the Anakin he knew no longer exists, having been "consumed by Darth Vader".
Subsequently, Yoda battles Palpatine in a lightsaber duel that wrecks the Senate Rotunda. At the climax of the duel, Yoda holds back the Sith Lord's Force lightning, creating a blast of energy that knocks him to the Senate floor. Yoda is forced to retreat and go into exile on Dagobah so that he may hide from the Empire and wait for another opportunity to destroy the Sith. At the end, it is revealed that Yoda has been in contact with Qui-Gon's spirit, learning the secret of immortality from him and passing it on to Obi-Wan.
Yoda is also instrumental in deciding the fate of the Skywalker children after Padmé dies in childbirth, recommending that Luke and Leia be hidden from Vader and Palpatine in remote locations. Other than the ancient Jedi Master, only the Organas, the Lars family, R2-D2 and Obi-Wan know of their true identities.