-Steve Rogers, 2015
A year has passed since S.H.I.E.L.D. collapsed with the reemergence of the terrorist organization HYDRA. With S.H.I.E.L.D. no longer heading their operations, the Avengers reassemble for the first time in three years to track down and eliminate HYDRA cells themselves, using Tony Stark's resources to help. Their latest mission brings them to the location of the alien scepter that Loki utilized during the Chitauri Invasion; the Scepter is now in the possession of Baron Wolfgang von Strucker, one of the notorious heads of HYDRA who has been using energy drawn from the alien weapon to power advanced weaponry, as well as attempting to empower living humans.
A raid on Strucker's base in the Eastern European country of Sokovia commences, with the Avengers battling HYDRA forces to reclaim the scepter. During the battle, without Strucker's approval, two of his agents join the fray: Pietro and Wanda Maximoff, Sokovian twins who are the only humans to have survived exposure to the scepter's energy, and have gained supernatural powers as a result. Pietro can move at superhuman speeds, while Wanda possesses a powerful plethora of psionic powers. The twins are able to hold their own against the Avengers but are unable to prevent the heroes from capturing Strucker.
Stark finds the scepter, and Wanda attempts to stop him by using her powers to implant a vision into his mind. In his vision, Stark sees his teammates dead or dying while the Chitauri launch an even larger invasion on Earth. Upon seeing Stark's nightmare, Wanda suspiciously allows him and the Avengers to take the scepter away before fleeing with her brother.
With Strucker's arrest, HYDRA has suffered a great blow and the organization is left in a state of discord. Returning to Avengers Tower with the scepter, Stark and Bruce Banner begin studying the weapon. Their research leads to the discovery of a net of neurons that, according to Stark, could be reconfigured into an artificial intelligence stored inside the scepter's gem. The two scientists extract it for use in Stark's secret peacekeeping program – "Ultron" – designed to allow the Iron Legion to operate independently and safeguard Earth under the direction of an advanced A.I.
After three days, the project is seemingly met with little success. However, while the Avengers throw a party to celebrate their recent victories, Ultron suddenly activates. Somehow already self-aware despite Stark's work has not made it that far ahead, Ultron immediately determines that the only way to save Earth is to eradicate humanity, which he deems as the prime factor in the planet's turmoils. J.A.R.V.I.S. attempts to stop Ultron, but the more powerful A.I. appears to destroy him and then takes control of the Iron Legion armors. After the Avengers have finished their party, the team, joined by Maria Hill, James Rhodes, and geneticist Helen Cho hold a small contest to see who can lift Mjølnir.
Their contest is interrupted when Ultron suddenly directs the Iron Legion to attack them, and an intense battle ensues. During that battle, Ultron has a chance to kill Cho but mysteriously spares her life. While most of the Iron Legion is destroyed by the Avengers, one drone manages to escape with the scepter and flees to the Sokovian HYDRA base, where Ultron uses the HYDRA technology stored there to begin construction of an army of robotic drones as well as his own mobile unit.
After the battle, the team confronts Stark about his secrecy, while Ultron recruits the Maximoff twins, who have a vendetta against Stark because a Stark Industries bomb killed their parents; Wanda had willingly allowed Stark to make off with the scepter with hopes that his fear of letting the world die would lead to him constructing his own undoing, which in this case appears to be Ultron. After Ultron kills Strucker to lure the Avengers out, he and the twins travel to South Africa to acquire vibranium from arms dealer Ulysses Klaue. The Avengers try to stop them, but Wanda hypnotizes Thor, Black Widow, and Captain America, giving them vivid hallucinations that render them invalid.
She then hypnotizes Banner, turning him into the Hulk and sending him to attack Johannesburg. Iron Man decides to call in "Veronica", which deploys the Iron Man Armor: Mark XLIV armor Stark needs to defeat the Hulk, but the destruction they cause starts a public backlash against the Avengers, who are forced to go into hiding.
The team takes refuge at Clint Barton's Homestead, where they meet his wife Laura and children Cooper and Lila. Having experienced apocalyptic visions in his hallucination, Thor leaves, traveling to the mystical "Water of Sights" to determine the meaning of his hallucination. Romanoff and Banner plan to run away and start a new life together when Ultron is defeated. Nick Fury arrives at the homestead and encourages the Avengers to form a plan to stop Ultron. Banner deduces that Ultron is planning to create another body made of synthetic tissue, using the "Cradle" device developed by Dr. Helen Cho.
Meanwhile, Ultron, Pietro and Wanda go to Dr. Cho's laboratory in Seoul, South Korea, where Ultron reveals his plan to use the vibranium samples in conjunction with Cho's synthetic tissue generating Cradle device to create a more powerful body for himself, with the scepter's gem as its primary power source. To ensure her cooperation, Ultron takes control of Cho's mind with the scepter.
As Ultron transfers his consciousness into the synthetic body and Cho implants the gem into its forehead, Wanda curiously looks into Ultron's mind and discovers his plan to destroy humanity. Horrified, the twins turn against Ultron, who leaves the laboratory with the Cradle. Arriving in Seoul, Captain America, Black Widow and Hawkeye battle Ultron, who kidnaps Black Widow and derails a train to slow the Avengers down. The twins aid Captain America in rescuing passengers from the train, while Hawkeye retrieves the Cradle and takes it back to Avengers Tower.
At Stark Tower, Stark and Banner upload J.A.R.V.I.S. – which survived Ultron's earlier attack by escaping into the internet – into the synthetic body as an attempt to rectify their mistake with Ultron. Believing Stark is about to potentially create another Ultron, Captain America and the twins try to stop them, but Thor arrives and brings the body to life with lightning.
The resulting being thankfully proves friendly. Thor explains that the scepter's gem is the Mind Stone – one of the six Infinity Stones, the most powerful objects in existence – which Thor saw in his hallucination, and its power could be advantageous against Ultron. The twins and the synthetic being, who is later given the name "Vision", ally themselves with the Avengers, who return to Sokovia to end Ultron's threat once and for all.
Arriving in Sokovia, the Avengers find that Ultron has used the remaining vibranium samples and Chitauri anti-gravity technologies being studied in the HYDRA facility to build a machine that lifts a large part of Novi Grad, the Sokovian capital, into the sky. His intent is to crash it into the ground to replicate a meteor strike, causing a mass extinction event. While Banner rescues Romanoff, the Avengers evacuate civilians from the city and fight Ultron's army of robots, but they are unable to evacuate everyone before the city begins to ascend. Fury and the revived S.H.I.E.L.D., joined by War Machine, arrive in a Helicarrier to assist in evacuating the last few civilians.
Black Widow and Banner, now transformed into the Hulk, enter the fray and the team converges on the location of Ultron's device. There, they wipe out most of Ultron's drones and severely damage Ultron's primary body. In retaliation, Ultron hijacks the Avengers' Quinjet and kills Pietro. The Hulk leaps into the jet and tosses Ultron to the ground, where a grieving Wanda finds and destroys him.
One of Ultron's drones deactivates the device, causing Novi Grad to begin plummeting towards the Earth, and forcing the other Avengers to flee aboard the Helicarrier alongside the evacuated citizens. Meanwhile, Iron Man fires his Unibeam and Thor summons a lightning strike to reflect off the Vibranium core. The ensuing explosion shatters the city into rubble, which falls safely into a nearby lake. The Hulk, seeking peace after the battle, gets Romanoff to safety and departs in the Quinjet. Ultron's consciousness attempts to flee in the last remaining drone, but the Vision confronts him. The two have a brief exchange of ideals before the Vision obliterates the drone, effectively ending Ultron's threat.
The Avengers establish a New Avengers Facility in upstate New York, run by Fury, Cho, Maria Hill and Erik Selvig. Romanoff assumes Banner is dead because the Quinjet cannot be tracked, and silently mourns for him, but Fury assures her that he is likely still alive. Believing the Mind Stone is safe with Vision, Thor returns to Asgard to learn more about the Infinity Stones, while Barton and Stark also leave the team. Captain America and Black Widow assemble a new Avengers team, consisting of Scarlet Witch, Falcon, War Machine and Vision.
Meanwhile, Thanos retrieves an Infinity Gauntlet saying "Fine, I'll do it myself." and then begins his crusade for the Infinity Stones.