According to the state news agency Maghrib Arab Press (MAP) on Monday, Muhammad Yasin Mansuri has been appointed to the post of chief spy master.
Mansuri - a former school mate of the king and a close aide who worked to improve relations with Spain after last year's Madrid train attacks - is to "help mainly the fight against terrorism".
The 42-year-old replaces outgoing Brigadier-General Ahmad al-Harshi as director of Direction Generale des Etudes et Documentations (DGED), MAP reported.
Mansuri is a former head of MAP and later chief of internal affairs at Morocco's Interior Ministry in charge of sensitive issues such as the Western Sahara dispute, security issues, illegal migration and the smuggling of locally produced cannabis to Europe.
After the train bombings in Madrid last year, he played a key role in improving ties with Spain by stepping up Morocco's cooperation in the investigation into the attacks.
The investigations have suggested the Madrid attacks were partially funded by the trade of cannabis smuggled from Morocco to Europe, which generates an annual street turnover of $13 billion.
DGED acts as the key platform for the exchange of information with foreign governments and gathers intelligence on external threats.
It employs both military and civilian staff and enjoys total autonomy from other security agencies.
Since its creation after a failed coup against King Muhammad's father in 1972, DGED had been led only by senior army officers, official sources said.