Gabon's President Ali Bongo Ondimba arrived on Thursday in Rabat, the Moroccan capital, to convalesce after a month's treatment at a Saudi hospital, a Moroccan diplomatic source has told the AFP news agency.
State media in Saudi Arabia had earlier said the president had left the King Salman air base on Wednesday night, where he was seen off by officials from the Saudi foreign ministry.
The president's wife Sylvia had said earlier this week in a post on Facebook that Bongo would be transferred to Rabat on Wednesday to continue his recovery.
Bongo, 59, had been at the hospital in Saudi Arabia since 24 October, when he fell ill during the Future Investment Initiative conference in Riyadh.
After an extended period of silence, the Gabonese presidency eventually admitted he was "seriously ill" and had undergone surgery, while insisting he was on the mend.
READ MORE ►
His recovery would take weeks, or even days, according to a source in the presidency.
The Gabonese president and Morocco's King Mohammed VI have had a close relationship since their youth.
Over the past month, the Gabonese presidency has released only two statements on Bongo's health, first saying on 29 October that he had been taken to hospital "suffering from severe fatigue".
Then on 11 November, Bongo's office admitted he was "seriously ill" and had undergone surgery.
Lack of official news, along with memories of the secrecy-shrouded death of Bongo's father Omar Bongo in 2009 after decades at the helm, had sparked numerous rumours, including speculation he was incapacitated or even dead.
Earlier this month, a foreign source close to Bongo and his French-born wife told AFP the Gabonese president had had a stroke.
Gabon was among the original members of the Organisation of the Petroleum Exporting Countries (OPEC), and remained in the cartel between 1975 and 1995. In 2016, Ali Bongos administration rejoined the group.
According to analysts, Bongo has used the country's membership of OPEC and his Muslim identity as a means to nurture stronger relations with the Saudi government.
In the early days of the Gulf dispute in 2017, Gabon openly sided with Saudi Arabia in its dispute with Qatar.
Speaking to Middle East Eye last week, Douglas Yates, a lecturer in African politics at the American Graduate School in Paris, said Bongo has also used improved ties with Saudi Crown Prince Mohammed bin Salman to get closer to US President Donald Trump.
Gabon enjoyed good relations with former US President Barack Obama and was seen as an asset to US foreign policy on the continent.
The country was also the first African nation to call for Libya's Colonel Muammar Gaddafi to step down in 2011.
Yates said Bongo had a lot in common with Mohammed bin Salman because both men shared a dynastic style of leadership.
"I think Bongo feels very comfortable with the Gulf. And when you consider that when he had his stroke, he was in Saudi Arabia, he couldnt have been luckier," said Yates.
"He got top treatment, he got his secrecy. Saudi Arabia offers him everything that he wants."