The Alaouite dynasty , to which the current Moroccan royal family belongs , established a sultanate in Morocco beginning in the 17th century .