I'm gonna be honest, I don't remember this one very clearly, since I've since watched an entire other season of Doctor Who. But I shall do my best.
The Master has returned, resurrected by an imprint, I'd guess, on his ring. But something went wrong, and he's a little crazy. Well, more crazy than before, with an insatiable hunger. The Doctor teams up with Donna's gramps, Wilf. There's this dude who is trying to create some sort of machine that will make his daughter live forever, and the Master is kidnapped to try to fix it to make it work. Of course, the Master rigs it so that it turns everyone on the planet into the Master. Except for a couple of people, of course, such as Donna, Gramps, and the Doctor.
Now we get to the spoilers. Over the course of the first part, we see flashbacks and hear voice-overs from the Timelords. It is revealed that the Master is going to try to bring the Timelords back. They had put the drumbeat into the Master's head, cuz apparently it's the heartbeat of a Timelord, and set it all up so that they could come back into the present day, bringing everything with them (Gallifrey, the Time War, etc) where they would end time itself and become gods. They sound like lovely people.
The Doctor has a gun. With one shot in it. He struggles a lot in this episode about whether he should kill someone. Obviously his gut tells him no, but Wilf in a very emotional outburst begs him to kill the Master so he (the Doctor) can live. And he goes back and forth, first between killing someone, then between killing the Master or the Timelord leader person, finally deciding on shooting the machine that had made the whole planet the Master, breaking the signal to the Timelords, sending them back to die again.
Meanwhile, Wilf got himself stuck in some machine thing with two compartments. There has to be one person in one of the compartments at all times, so the worker people would switch off, so when one went in, the other could come out. Wilf knocked four times on the window. He asked the Doctor to let him out. The Doctor found out that the machine, if it was opened and closed again would release intense radiation, which would kill the Doctor. He had a little bit of a pity party, which was entirely justified and moving, and, despite Wilf's pleas to let him die instead, the Doctor went in.
And the regeneration process was begun. Before he died, the Doctor went back and visited all of his past friends for closure. He visited Martha and Mickey, who apparently got married. He visited Donna and gave her a winning lottery ticket. And he visited Rose. Before she had met him, on New Year's Day. Then it was time.
And voila! Matt Smith. Who's still got legs, and isn't a ginger.