Hank Pym's recent robotic creation Ultron turns against his creator, breaking out of Pym's lab, claiming he will wipe out the human race in an attempt to create a better world. Pym contacts Nick Fury, who re-activates the Avengers Intiative.
Ultron distracts the Avengers by luring the alive supervillains together, forming a temproary alliance - (Masters of Evil) who then fight them. IN the mean time Ultron breaks into the Helicarrier and uses Phil Coulsons body from the mourge to create a Human-Cyborg, his 'Vision' of the perfect human.
The Avengers return after the battle to find many SHIELD agents dead, Vision and Ultron being the cause. Ulytron reveals his plan to wipe out the human race by hacking into every network in the world, and firing America's nuclear missiles, which would then start a nuclear war. The Masters of Evil come back to attempt to again defeat the Avengers, meanwhile Ultron activates his master plan. Pym escapes the battle and goes to stop Ultron, but Vision attacks him. Pym tries reasoning with Vision, reminding him that he used to be human. Vision's human side then starts taking over, and he turns on his creator, and beats him down (ala Hulk and Loki), and Pym stops the nuclear missiles. The rest of the team defeat the Masters of Evil, however critically damaging the Helicarrier. Iron Man, Thor and Vision catch the ship before it hits New York, and fly it back to the Ocean, placing it down in the sea.
Fury thanks the heroes and forgives Pym for creating Ultron, as he eventually solved the problem. Fury decides to keep Vision with SHIELD, and the team once again say their goodbyes. At the end of the film as Fury is observing the remaining SHIELD agents clean up the ship, he turns to see Star-Lord, who warns Fury that Thanos plans to destroy Earth, and that they should prepare for all out war. Fury smiles, "We're always prepared." Star-Lord responds, "Not for this." and leaves.
The after credits could be Thanos preparing to invade Earth, with the Other filling him in on what happened on Earth.