The short version: They form a vagina in the pelvis and reuse the head of the penis to form a clitoris. The urethra is also rerouted.
Caveat: I am nothing more than a layperson on the subject. My short version may be wrong, and there may be other surgeries available.
The longer version: Wikipedia  has quite a bit of information on the subject. Use incognito mode if you must; I've always found it to be a fascinating subject.
: http://en.wikipedia.org/wiki/Sex_reassignment_surgery (No images if you're worried about that.)