Arabic and Berber are official languages in Morocco. However, local Moroccan Arabic, a dialect of Maghreb Arabic (spoken in Morocco, Tunisia and Algeria), is very different from Standard Arabic, so even native Arabic speakers from outside the region would not understand the conversations of the locals. However, all Moroccans learn Standard Arabic at school, so speakers of Standard Arabic should have no problem communicating in the larger cities. Officially, about half of the population cannot read or write, so there are always translators and people to help fill out forms (for a small fee) in most places where such forms are needed, such as ports, etc.
Various dialects of Berber are spoken by the ethnic Berbers of Morocco.
French is widely spoken in Morocco due to its history as a French protectorate and is still taught in schools from relatively early grades, making it by far the most useful non-Arabic language to know. Most urban locals you meet are trilingual in Moroccan Arabic, Standard Arabic and French. In the north and south of the country, many people also speak Spanish instead of or alongside French.
While knowledge of English is increasing among the younger generations, most Moroccans do not speak a word, and even those who do are most likely to speak French better. Although you will find a few people who speak English among the most educated, in urban areas most of them are touts and false guides. Some shopkeepers and hotel managers in urban centres also speak English.
People are used to dealing with the communication barrier that comes with the different Berber dialects – mime, smile and even broken French will get you far.