Rabat is the capital of Morocco.
If you are heading into Mauritania, Rabat is the only place to get a visa. There is no longer a Mauritanian consulate in Casablanca and visas are not available on the border. The bus to the embassy is 26a, which you can catch at Avenue Patrice Lumumba in the center.
To get to Fes, go to the Bab el-Bouiba (one of the gates to leave the Medina) and follow the road towards the shell petrol station you can see down the lane. Across the street from the Medina there's a bus stop, go over there and ask somebody which bus to take to the road to Fes (it's one of the ones waiting there). You'll get out at a petrol station, so you can chose to ask around there or walk down the road a couple of hundred meters where there's ample space for cars to pull over, and start hitching.
South towards Casablanca, Marrakech
Take bus no. 4 or 32 from Rabat's Bab el Had to a stop called Guich Lwdaya (about 45 minutes; 3,60 dirham). From there walk in the direction the bus has come from for 100 meters or so and turn left to hitch. Have a sign.
CRCulver isn't sure which road the above advice is for, but he recommends getting onto the motorway. The national road between Rabat and Casablanca passes through endless suburbs, and you'll find it tiring to avoid all the taxis. Standing at a motorway entrance with a sign, however, should get you a direct lift at least to Casablanca.
North towards Tanger
Take bus no. 18 from Bab el Had to a stop called Hay Senaai. Walk back to the roundabout and hitch, best with a sign.