You can easily get to CasaBlanca by bus or plane and then grab a taxi or walk to get to the Mosque.
City of Marrakesh
Marrakesh is well-connected by public transport. Take a train from Casablanca or a bus from major cities; Marrakesh Menara Airport