Ahmed easily won a parliamentary run-off vote on Saturday against Maslah Mohamed Siad, the son of ex-president Mohamed Siad Barre, taking 293 votes to Siad's 126, to become president.
Somalia has not had effective central government since 1991, when Barre was forced from power.
Mohamed Nur, a Somali journalist based in Mogadishu, the capital, told Al Jazeera that people had taken to the streets to celebrate Ahmed's victory.
Ahmed has vowed to form a broad-based government and invited all armed groups in Somalia to join a UN-sponsored reconciliation effort.
Ahmed had been critical in his assessment of past US administrations' influence on Somalia.
He led the Islamic Courts' Union before the US backed a 2006 Ethiopian invasion with the purpose of driving the group from power.
In 2008, Ahmed condemned the US after an air raid killed a Muslim leader in central Somalia.
The last of the Ethiopian troops left Somalia in January and a new US administration under Barack Obama took office in the same month.
Abdullahi Yusuf, the former Somali president, resigned on December 29 after he was accused by the major powers of being an obstacle to peace.
Ahmedou Ould-Abdallah, the UN's special envoy for Somalia, praised Saturday's "transparent" presidential vote.