Sheikh Sharif Sheikh Ahmed has been sworn in as the new president of Somalia just months after his Alliance for the Re-Liberation of Somalia (ARS) signed a peace deal with the transitional government.
The ceremony in neighbouring Djibouti on Saturday came after Ahmed, who also led the Islamic Courts Union, won a run-off parliamentary vote.
The new president's Islamic Courts movement ruled Mogadishu and most of southern Somalia for six months before being ousted by the Ethiopian military at the end of 2006.
Ahmed easily defeated Maslah Mohamed Siad, the son of ex-president Mohamed Siad Barre, in Saturday morning's second round of voting, winning 293 votes to Siad's 126.
"My government will bring an adequate plan to overcome the difficulties the nation is facing," he said in a brief inauguration speech.
"I will deal with the humanitarian situation in the country and give priority to those who have been displaced by war."
Mohamed Nur, a Somali journalist based in Mogadishu, told Al Jazeera that people had taken to the streets to celebrate their new president.
"They think he is the best leader ever [to be] chosen as president of Somalia since 1960, when the country gained independence," he said.
Ahmed's other main rival, Nur Hassan Hussein, the prime minister, pulled out of the election after the first round.
The Somali transitional parliament held both the presidential vote and the swearing-in ceremony in Djibouti due to instability in its home country.
Ahmed vowed to form a broad-based government and invited all armed groups in the war-ravaged Horn of Africa nation to join the UN-sponsored reconciliation effort.
After being elected, he said he would reach out to former government leaders as well as to al-Shabab, the former armed wing of the Islamic Courts movement.
"Very soon, I will form a government which represents the people of Somalia," Ahmed said after being elected. "We will live peacefully with East African countries and we want to co-operate with them."
"I am extending a hand to all Somali armed groups who are still opposed to this process and inviting them to join us."
Al-Shabab has vowed to carry on fighting and already controls much of south and central Somalia, as well as large areas of Mogadishu, the capital.
After the swearing-in ceremony, Ahmed was expected to fly to Ethiopia for an African Union (AU) summit before returning to Somalia to put together his government.
Abdirahman Abdi Shakur, an adviser to the president's party, told Al Jazeera that security was one of the main issues Ahmed would seek to tackle.
"I would say that there will be huge challenges and at the same time opportunities," he said.
"We are finally seeing progress from the hard work by all sides to create an inclusive parliament"
Ahmedou Ould-Abdallah, UN's special envoy for Somalia
"Our approach is reconciliation not confrontation and we try to speak to everyone wherever they are in our country."
Abdullahi Yusuf, the former Somali president, resigned on December 29 after he was accused by the international community of being an obstacle to peace.
As part of an agreement brokered by the UN between the opposition and the transitional government, parliament was expanded to 550 seats, with 200 members of Ahmed's ARS group being sworn in earlier in the week.
Another 75 seats are still to be filled by other opposition and civil society groups, as part of an effort to bring former opponents into the government.
The parliament voted on Wednesday to extend by two years the term of the transitional government. Its original term of five years would have ended in seven months.
Ahmedou Ould-Abdallah, the UN's special envoy for Somalia, praised Saturday's "transparent" presidential vote.
"We are finally seeing progress from the hard work by all sides to create an inclusive parliament," Ould-Abdallah said in a statement.
"It is up to you, the fathers, mothers, brothers and sisters to prevail on your children, your young brothers and friends to stop the violence. For the last 20 years, it has not helped any group to win lasting victory."
Somalia has not had an effective central government since 1991, when Mohammed Siad Barre was forced from power.