Somalia’s MPs have elected a Somali-US national as the country’s new president in a vote held in an aircraft hangar.
Ex-Prime Minister Mohamed Abdullahi “Farmajo” Mohamed beat President Hassan Sheikh Mohamud in two rounds of voting.
The vote was held at the heavily guarded airport complex in the capital, Mogadishu, as the rest of the country is not safe.
Traffic was banned and a no-fly zone imposed over the city to prevent attacks by militant Islamists.
Despite this, suspected militants fired mortar rounds close to the venue on Tuesday night.
Somalia has not had a one-person one-vote democratic election since 1969.
That vote was followed by a coup, dictatorship and conflict involving clan militias and Islamist extremists.
Mr Mohamed’s election is part of a lengthy and complex process to help the East African state rebuild its democracy and achieve stability.
Thousands of Somalis quickly took to the streets to celebrate his victory and cheering soldiers from the Somali army fired into the air, the Associated Press news agency reports.
More than 20,000 African Union (AU) troops are stationed in Somalia to prevent militant Islamist group al-Shabab from overthrowing the weak government.
A total of 21 men ran for the presidency, but the number was reduced to two after two rounds of voting.
Mr Mohamed obtained 184 votes, compared with 97 for the outgoing president.
Mr Mohamud accepted defeat, avoiding a third and final vote.
“History was made, we have taken this path to democracy, and now I want to congratulate Mohamed Abdullahi Farmajo,” Mr Mohamud said in his concession speech.
The new president is popularly known as “Farmajo”, Italian for cheese, because of his love for the dairy product.
Much of Somalia was a former Italian colony.