Following from "The Pandorica Opens", the Doctor has been sealed in the Pandorica, a trap created by his greatest enemies; River Song is trapped aboard the exploding TARDIS; and an Auton version of Rory has shot and killed his fiancée Amy. The TARDIS's explosion has caused the whole universe to have never existed, except for the Earth, its moon, and a sun-like object, otherwise leaving a dark infinite void. Only stone versions of the Doctor's foes surround the Pandorica.
As Rory is mourning over Amy, the Doctor appears using River's vortex manipulator. He hands Rory his sonic screwdriver and explains how to use it to open the Pandorica and free his younger self. Following these instructions, Rory frees the Doctor, who then places Amy's body inside the Pandorica. He explains that the Pandorica, being the "perfect prison", will restore her once given an imprint of her DNA. The Doctor then retrieves River's manipulator and uses it to jump ahead nearly two millennia; Rory, in his ageless Auton body, decides to stay with the Pandorica and guard it, creating the myth of "The Last Centurion" over the years.
In 1996, seven-year-old Amelia Pond (Caitlin Blackwood) finds instructions from the Doctor leading her to the National Museum, where the Pandorica is on display. She touches the box, allowing it to revitalise Amy and release her. They are soon joined by the Doctor and Rory, now a museum guard. After a tearful reunion, they are chased by a Dalek restored by the light of the Pandorica. The Doctor uses the vortex manipulator to go back and give Rory his screwdriver, as well as leave Amelia the clues to the museum. Amelia soon disappears: a sign, according to the Doctor, that the universe is collapsing rapidly. The injured body of a future version of the Doctor appears and whispers something to his earlier self. The Doctor takes off with Amy and Rory to the roof of the museum, where he discovers that the "sun" is the still-exploding TARDIS. Rory hears a voice coming from the exploding TARDIS and the Doctor amplifies the voice and discovers it is River Song in a time-loop, implemented by the TARDIS to keep her alive. The Doctor saves River, and as the quartet reunites, the Doctor is shot by the Dalek and sends himself backwards in time. Amy and Rory depart while River threatens the Dalek before shooting and destroying it.
Amy and Rory discover that the wounded Doctor had told his earlier self to create a diversion, allowing him to rig the Pandorica to fly into the TARDIS explosion. The Doctor postulates that enough of the original universe still exists in the Pandorica to completely restore it via the exploding TARDIS. After a tearful farewell to Amy, Rory, and River, the Doctor engages the Pandorica and flies it into the exploding TARDIS. A second Big Bang occurs. The Doctor comes to consciousness and begins witnessing events in his life in reverse as the cracks in the universe close. The Doctor has to stay outside this new universe in order for that to happen.
Amy wakes on 26 June 2010 in her home to discover that her parents have been brought back into existence and she and Rory celebrate their wedding day. At the reception, River leaves her blank diary for Amy which prompts Amy to recall the Doctor and something he told her when she was seven during his rewind. She interrupts her father's speech, imploring the Doctor to come back. As she recites the old wedding proverb ("something old, something new, something borrowed, and something blue"), relating that to what the Doctor had said about the TARDIS, the TARDIS and the Doctor appear. The Doctor joins the wedding festivities and afterwards, he returns River's diary and the vortex manipulator to her so she can return to her own time. She sadly tells him he will soon learn who she truly is and that it will change everything. Aboard the TARDIS, the Doctor explains to Amy and Rory that unanswered questions remain about the destruction of the TARDIS and the nature of "the silence" that will fall. The Doctor receives a telephone call alerting him to the presence of an escaped Egyptian goddess on the Orient Express in space. Rory and Amy decide to join him, and the three leave on their next adventure.