The train journey from Tangier to Marrakech is one of the best I've been on. You can't purchase tickets outside Morocco, but we had no problem buying them on the day. The trains are comfortable and spacious and very cheap (the 10 hour trip cost about £20, imagine that in the UK!?)
We met some interesting characters on the train, who were eager to talk to us and help us when it came to switching trains. Perhaps the best thing though is that you get to see the countryside and small towns along the way that you would normally be flying over! Well worth the slight more effort involved!