Nizam (Ben Kingsley) poisoned the shawl, as Dastan (Jake Gyllenhaal) realizes by observing his burned hands, realizing he was never there when the shawl killed Sharaman.
Dastan manges to gain the trust of his brothers, but not before they are killed by Nizam's forces.
Nizam and Dastan make it to the heart of the sands of time, where Tamina sacrifices herself so that Dastan can stop Nizam from turning back time to when he saved his brother from a lion so that he could be king. Ultimately, Dastan gains the upper hand, travels back to the invasion of Alamut, as the only person with knowledge of possible future events.
Dastan outs Nizam for his plot. Nizam tries to kills Dastan, but is killed by Sesan.
They approach Tamina to apologize for the invasion. Sesan offers his apology on behalf of Sharaman by uniting their kingdoms in marriage to Dastan. Though reluctant at first, Tamina is charmed by Dastan, and offers to go for a walk with him.