There is Mauritanian embassy at Rabat but note that the embassy in Rabat no longer has a consular section and does not issue visas. So you have to go to Casablanca to the Mauritanian consulate. The Mauritanian consulate in Casablanca issues visas to all nationalities and process is straightforward and easy.
You will find the Mauritanian consulate at 382 route d'El Jadida, in the Quartier Beau Sejour. The opening hours of the consulate are: Monday to Friday from 8.30 AM until 3 PM, Friday from 8.30 AM until noon. You can call the consulate at 02 223 73 73.
The visa costs 200 dirham (about US$ 20). You will need to bring two passport sized photographs. If you file your application before 9 AM, you should be able to pick up the visa after 1 PM the same day. Sometimes you have to provide photocopies of the first passport pages - it can be easily done at copy shop close to consulate.
The best way to get to the consulate is by taxi. This should cost no more than 20-25 dirham from Casablanca city center.
It should be also possible to get your visa on the border between Morocco and Mauritania at Nouadhibou. This is much more expensive, US$ 45. Check situation with embassy before heading to the border without visa.