Mansouri, who until her nomination also was the mayor of Marrakech, was tasked with forming a new government, the Royal Palace said in a statement.
The announcement came four days after results of parliamentary elections were announced, with Mansouri's centrist Authenticity and Modernity Party, or PAM, the highest vote-getter.
Mansouri, the second woman to serve as prime minister in the Arab world after Najla Bouden in Tunisia, is expected to build a coalition in coming days to form a government.
Morocco's electoral system makes it difficult for a single party to win an absolute majority.
Her government is expected to make billions of dollars in investments linked to the 2030 FIFA World Cup, while seeking to deliver on promises to fight inflation, raise wages and create jobs.
The Moroccan Constitution gives the king, who is the country's highest authority, the power to appoint the prime minister, but he must choose from the party that wins the most seats in parliamentary elections.
That was a change successfully pushed by Arab Spring protesters in 2011. Before that, the king could name the prime minister without any such restriction.
Mansouri joined PAM upon its creation in 2008 by Fouad Ali El Himma, a childhood friend and close adviser to the king. A law graduate from the University of Montpellier in France, Mansouri became one of the party's top leaders in 2024. She twice served as mayor of Marrakech and was a member of parliament.