Pope Francis, who has made building bridges between Christianity and Islam a cornerstone of his papacy, will visit Morocco in March, the Vatican said on Tuesday.
Francis, 81, will be the second pope to travel to Morocco, following John Paul II more than three decades ago.
He will take in Rabat and Casablanca on the March 30-31 trip to the Muslim-majority country, the Vatican said.
The pontiff was "accepting the invitation extended by King Mohammed VI and the bishops", it said.
Francis has already visited several Muslim countries, including Turkey in 2014, Azerbaijan in 2016 and Egypt in 2017.
John Paul II went to Morocco in 1985 on a trip that was also seen as an opportunity to build ties between Muslims and Christians.
"The late pope's visit to Morocco over 30 years ago drew headlines, as it was the first time a Roman pontiff had been invited to visit a Muslim country by the head of state, not the local church," said religious website Cruxnow.
John Paul II had been invited by the current king's father, Hassan II, who in turn visited the Vatican in 1991.
Over 99% of the population in Morocco is Sunni Muslim, with Christians, Jews, Shia Muslims and Bahais making up the rest. Just over 27 000 are Catholic, according to the Vatican Insider newspaper.
Islam is the state religion and the king describes himself as the "commander of the faithful".
Foreign Christians worship freely and are protected by the authorities. But those who convert to Christianity - estimated to be a few thousand people - do so quietly.
While renouncing Islam is not explicitly mentioned in the penal code, attempts to "undermine the faith of a Muslim or convert a Muslim to another religion" can be punished by jail sentences of up to three years.
Morocco's minister of state for human rights, Mustapha Ramid, said in June that freedom of conscience was a "threat" to the country's "cohesion".
Pope Francis moved quickly after his election in 2013 to make overtures to Jews and Muslims, inviting two old friends from Buenos Aires - a rabbi and a Muslim professor - on a trip to the Middle East where he condemned religious hatred.
But the Catholic Church has found it harder to bridge differences with Islam than with Judaism.
Benedict XVI angered the Muslim world with a speech in 2006 in which he appeared to endorse the view that Islam is inherently violent, sparking deadly protests in several countries as well as attacks on Christians.
Since then the Vatican's pontifical council for inter-religious dialogue has been working overtime to mend fences with moderate Islam - a task made no easier by the rise of the Islamic State group in Iraq and Syria.
Morocco is the only trip officially on Francis's schedule for 2019 after a visit to Panama scheduled for the end of January.
But the pontiff is also expected to visit Bulgaria, Japan, Madagascar, Mozambique and Romania next year.
The Vatican said it would be releasing the programme for Morocco at a later date.
Francis's decision to visit in March lays to rest rumours he planned to go to Marrakesh for a UN migration conference in December.