Relieved Moroccan footballers and support staff sang a hearty rendition of the national anthem as they departed Guinea after being holed up in their hotel during the first hours of a military uprising on Sunday.
Morocco's national team were in Conakry to play a World Cup qualifier on Monday, but awoke on the eve of the match to the sound of gunfire near their hotel as soldiers sought to topple Guinea's long-serving president Alpha Condé.
Moroccan diplomats were able to negotiate a departure for their team amid the uncertainty and the squad flew out of the country late on Sunday, just hours after the match had been called off.
Players posted pictures and video on social media of the passengers bursting into a spirited rendition of the anthem as the plane took off for Morocco.
When the flight landed in Rabat early on Monday, Paris St Germain fullback Achraf Hakimi (@AchrafHakimi) tweeted: "Thank you all for the messages and the support, it has been a very intense day but thank God we are safe and sound in Morocco."
The squad left their hotel for the hour-long trip to the Conakry airport in two buses, which were cheered by local residents who had come out onto the streets in support of the coup attempt.
Morocco coach Vahid Halilhodzic had earlier described the anguish of his squad as they were stranded in their hotel not far from the presidential palace.
"We heard gunshots nearby all day. We are waiting for permission to go to the airport, for the moment we are stranded. A plane is waiting for us, but we are not allowed to leave. The players are concerned," he told L'Equipe earlier on Sunday.
There has been no immediate word on the fate of Guinea's large contingent of European-based players, including captain Naby Keita of Liverpool and Florentin Pogba, the brother of Manchester United's Paul Pogba.
Toulouse defender Issiaga Sylla said the players were trying to find out how they could return.
"It's going to be a bit complicated to get back to Europe," he told L'Equipe, "we're worried about that".
"Everything is closed, the airport is closed. We went to see the coach to find out how it was going to go for us to return to our clubs. But we still don't know. We're 10 minutes from the airport, but we can't move."