Morocco's goals were scored by Driss Ghannam (2'), Réda Zahraoui (5', 15') and Badr Krichli (17'), while Mohame Ouali (5', 21', 31'), Mohamed Diallo (6') and Al Bachir Elaid (16'), Bidati Malik (18') and Ahmadou Bilal (35') scored for Mauritania.
In the final, the Mauritanian team will face its Senegalese counterpart on Saturday, while the ranking match will pit Morocco against hosts Egypt.
By qualifying for the final, Senegal and Mauritania have secured their spots for next year's Beach Soccer World Cup in the Seychelles.