In the Eastern European country of Sokovia, the Avengers – Tony Stark, Steve Rogers, Thor, Bruce Banner, Natasha Romanoff, and Clint Barton – raid a Hydra outpost led by Baron Wolfgang von Strucker, who has been experimenting on humans using the scepter previously wielded by Loki. They encounter two of Strucker’s experiments – twins Pietro, who has superhuman speed, and Wanda Maximoff, who can manipulate minds and throw energy blasts – and apprehend Strucker, while Stark retrieves Loki’s scepter.
Stark and Banner discover an artificial intelligence within the scepter’s gem, and secretly use it to complete Stark’s “Ultron” global defense program. The unexpectedly sentient Ultron, believing he must eradicate humanity to save Earth, eliminates Stark’s A.I. J.A.R.V.I.S. and attacks the Avengers during a victory party at their headquarters. Escaping with the scepter, Ultron uses the resources in Strucker’s Sokovia base to upgrade his rudimentary body and build an army of robot drones. He recruits the Maximoff twins, who want revenge against Stark for their parents’ deaths from his company’s weapons. Together, they visit the base of arms dealer Ulysses Klaue in an African shipyard to obtain vibranium. The Avengers battle them, but Wanda subdues the heroes with haunting visions, causing the Hulk to run ramped and forcing Stark to use his powerful “Veronica” armor to stop him.
A worldwide backlash over the resulting destruction, and the fears Wanda’s hallucinations incited, send the team into hiding at Barton’s safe house farm, where they meet his wife, Laura, and children. Thor departs to consult with Dr. Erik Selvig on the meaning of the apocalyptic future he saw in his hallucination. Realizing an attraction between them, Romanoff and Banner plan to flee together after fighting Ultron. Nick Fury arrives and encourages the team to form a plan to stop Ultron. In Seoul, South Korea, Ultron forces Banner’s friend Dr. Helen Cho to use her synthetic tissue technology, vibranium, and the scepter’s gem to create the perfect body for him. When Ultron begins uploading himself into the body, Wanda is able to read his mind; discovering his plan for human extinction, the Maximoffs turn on Ultron. Rogers, Romanoff, and Barton hunt Ultron and retrieve the synthetic body, but Ultron captures Romanoff.
The Avengers fight amongst themselves when Stark secretly uploads J.A.R.V.I.S. – who is still operational after hiding from Ultron inside the Internet – into the synthetic body. Thor returns to help activate the body with lightning, explaining that the gem on its brow – the Mind Stone, one of the six Infinity Stones and one of the most powerful objects in existence – was part of his vision. The synthetic being, now referred to as the Vision, and the Maximoffs accompany the Avengers to Sokovia, where Ultron has used the remaining vibranium to build a machine that lifts a large part of the city skyward, intending to crash it into the ground and cause global extinction. As the city begins to lift, Banner rescues Romanoff, who awakens the Hulk for the battle. The Avengers fight Ultron’s army while delaying Ultron from activating his plan’s final procedure. Fury arrives in a Helicarrier with Maria Hill, James Rhodes, and S.H.I.E.L.D. agents to assist in evacuating civilians, but Pietro dies when he shields Barton from a barrage of fire. A grieving Wanda abandons her post to destroy Ultron’s primary body in revenge, inadvertently allowing one of his drones to activate the machine. The landmass plummets, but Stark and Thor overload the machine and shatter the city into pieces. In the aftermath, the Hulk, unwilling to endanger Romanoff by being with her, departs in a Quinjet, while the Vision confronts Ultron’s last remaining body.
Later, the Avengers have established a new base in upstate New York, run by Fury, Hill, Cho, and Selvig. Believing the Mind Stone is safe with the Vision, Thor returns to Asgard to learn more about the forces he suspects have manipulated recent events. As Stark and Barton also retire from the team, Rogers and Romanoff prepare to train new Avengers: Rhodes, Wanda, the Vision, and Sam Wilson.
In a mid-credits scene, Thanos retrieves the Infinity Gauntlet2 and, dissatisfied with the failures of his pawns, vows to hunt for the Infinity Stones personally.