Tamina and Dastan, as well as Sheik Amar and Seso, return to Alamut to reveal the truth about Nizam and the dagger to Tus. First, they must get the dagger, which is kept in the sacred temple, guarded by the Hashshashin who killed Garsiv. Seso, the master of throwing knives, fights the spike-wielding Hashshashin to obtain the dagger. He manages to kill the Hashshashin after a well aimed throw, yet is fatally wounded in the process. Seso manages to throw the Dagger out of the window to Sheik and Dastan before dying. Sheik Amar then distracts the guards by serving as a decoy while Dastan shows the truth about the Dagger to his brother Tus by killing himself, only to have Tus rewind time with the dagger. Afterward, Tus is killed by Nizam, and Dastan is incapacitated by another Hashshashin. The Dagger is once again in Nizam's hands, but Dastan manages to defeat the Hashshashin with Tamina's help. She realises that the Hashshashin had been a spy inside the city of Alamut and must have been the one who told Nizam about the Dagger.
Nizam goes to the Sandglass caves beneath Alamut, as Dastan and Tamina race to stop him. Tamina opens a secret gate leading to the chamber, allowing them to take a short cut to the Sandglass. En route, they encounter the leader of the Hashshashins; however, after a close fight, Dastan gets the upper hand and stabs the Hashshashin before throwing him into the chasm. Dastan and Tamina then kiss. They then manage to reach Nizam as he pierces the Sandglass with the Dagger. During the final confrontation, Nizam knocks Tamina over the edge of the chasm and Dastan desperately catches her hand. Knowing he cannot stop Nizam and save her, Tamina professes her love for Dastan and lets go, sacrificing herself to stop Nizam. Dastan fights Nizam as they both hold their hands on the Dagger. Dastan then uses the Dagger's button to open the Sands of Time container and use its power against Nizam. The Sandglass slowly cracks and the sandstorm is shown destroying Alamut. Dastan is then able to use the Dagger and turn back the time as the Sandglass breaks, ending up at the point when he first held the Dagger during the siege of Alamut.
Dastan uses his knowledge to reveal Nizam's evil plan to his brothers, gaining their acceptance by revealing what Tus told him about the meeting with their father prior to the attack. Exposed, Nizam attempts to kill Dastan but ends up dying by Tus' blade. After apologizing for the ransacking of her city, Tus suggests that perhaps Tamina should become Dastan's wife as a sign of good will. The Prince returns the Dagger of Time to her as a gift, as she looks at him surprised. The two of them are next shown talking to each other and Tamina expressing her surprise about Dastan's sudden change in behavior and hinting that he may have discovered something to which he replies that they are in control of their own destiny.
In March 2004, the production company Jerry Bruckheimer Films sought to acquire feature film rights to the 2003 video game Prince of Persia: The Sands of Time with the film to be distributed by Walt Disney Pictures. Under John August as executive producer, the series' creator Jordan Mechner was hired to write the script. Producer Jerry Bruckheimer's Pirates of the Caribbean film trilogy served as a touchstone in how a theme park ride was converted into a film franchise. According to Mechner, "Rather than do a straight beat-for-beat adaptation of the new videogame, we're taking some cool elements from the game and using them to craft a new story." Mechner previously considered producing an animated film based on the games, but could not resist Disney and Bruckheimer's offer. In February 2006, Disney hired screenwriter Jeffrey Nachmanoff to write a new script for Prince of Persia.
Early in 2007, Disney announced Prince of Persia as one of its tentpole films and by June had scheduled a release date for July 10, 2009, before having a final script or any actors attached. By November 2007, Disney entered negotiations with Mike Newell to direct the film based on a script by Mechner and Nachmanoff, though the studio held off production until the 2007–2008 Writers Guild of America strike was resolved. Newell was fond of Bruckheimer's films, and loved the "exciting [and] immensely romantic" script, which reminded him of Lost Horizon. His assistant played the video games and gave the director key details. Mechner, in writing the script, re-conceived the storyline to shift the perspective from the interactive one experienced by video gamers to the non-interactive experience by film audiences. The screenwriter left out elements of the Prince of Persia video games Warrior Within and The Two Thrones and did not anticipate including these elements in the film's possible sequels.
When filming began, the film's release date was postponed to May 28, 2010, with the studio seeking enough time for the post-production process in designing the film's special effects. The profit margin on the Pirates of the Caribbean films was compromised by overspending as special effects teams rushed to complete the films for their release dates. Variety also ascribed the postponement to avoiding the potential 2008 Screen Actors Guild strike so the studio could ensure that the film leads to a "mega-franchise" similar to its successful Pirates of the Caribbean series. Other reasons for the release date change were that the film was originally scheduled a week before Transformers: Revenge of the Fallen, and Disney needed more time to co-ordinate its marketing campaign.
On May 20, 2008, it was announced that Jake Gyllenhaal would portray Dastan, the protagonist of the film. Producer Jerry Bruckheimer explained his choice, "He's a wonderful actor. He's someone I've been watching for a long time and somebody I've always wanted to work with." Gyllenhaal claims he "over-prepared" for the role, gaining five or six pounds of muscle. The actor says, "…I never knew how much they were going to ask me to do, so I just made sure I'd be hopefully able to do anything." Gemma Arterton was announced to play the role of protagonist Tamina, and Arterton reported she practiced horse back riding in Madrid before filming. Sir Ben Kingsley was to portray the film's antagonist, Nizam. Alfred Molina was to portray a character named Sheik Amar, who becomes a mentor to the prince. Toby Kebbell was to play Prince Garsiv, Dastan's brother, and head of the Persian army. The leading characters of the film all speak with a recognisable British English accent, albeit with a slight Middle Eastern colour.