The Koutoubia was built by the Almohades, but the minaret (which looked awfully familiar) was apparently designed in Spain under the Almoravides. In actual fact, it’s a carbon copy of the Giralda in Seville.
Here it is, seen from the Jmaa El Fna, against the sunset.