Somalia's President Sheikh Sharif Sheikh Ahmed came to prominence as one of the leaders of the Union of Islamic Courts, which controlled most of southern Somalia for six months in 2006
He was always seen as the moderate face of the UIC and was elected by MPs after agreeing a peace deal with the Western-backed government.
A former schoolteacher, he started to stand up to the warlords who had fought for control of Mogadishu since 1991, when one of his 12-year-old pupils was abducted.
Born on 25 July 1964 in the Middle Shabelle region, Sheikh Sharif Sheikh Ahmed is from the Hawiye clan (Abgal branch) - one of Somalia's four main clans, which dominates in the capital.
He studied at Libyan and Sudanese universities in the mid-1980s.
Mr Ahmed returned home to Jowhar in 2002, at a time when Abdulkassim Salad Hassan's government was trying to establish control of Mogadishu.
He worked against Mr Hassan with Mohamed Dhere, a warlord and his fellow clansman, who was then in charge of Jowhar.
Mr Ahmed became chairman of the regional court in Jowhar, but the alliance with the warlord did not last and in 2003 he fled for Mogadishu.
Mr Ahmed started teaching geography, Arabic and religious studies at the city's Jubba Secondary School.
That same year one of his pupils was snatched - amid a wave of abductions in Mogadishu - and the gang responsible demanded a ransom from the 12-year-old boy's parents.
Mr Ahmed was disturbed by the fact the kidnapping took place in an area dominated by his own clan.
It was a moment he would later call a turning-point.
Somalia's future president began campaigning within his local community to establish an Islamic court, of which he would be elected the leader.
The Islamic court managed to secured the release of his pupil and other abductees.
Mr Ahmed and others then began campaigning to combat the crime and banditry rampant in the poor neighbourhoods of north Mogadishu.
The five branches of the Islamic courts united to form the Union of Islamic Courts (UIC) and Mr Ahmed, who comes from a long line of religious leaders, was chosen to become the chairman.
The UIC rose to take control of the capital and large parts of south and central Somalia, driving out a US-backed alliance of "anti-terrorism" warlords from Mogadishu.
During their six months in power, the Islamic courts were divided between moderates and hardliners, with Mr Ahmed viewed as the moderate leader.
The UIC was itself ousted in December 2006 by an Ethiopian-led force.
Date with destiny
Mr Ahmed surrendered to Kenyan security forces three weeks after his group was routed from Somalia.
Can Somalia's new president tame a radical Islamist insurgency?
Between 2007-2008 Mr Ahmed was an exiled leader of a faction within the Eritrea-based Alliance for the Re-liberation of Somalia (ARS).
A UN-backed peace process between moderate Islamists and the fragile Western-backed Transitional Federal Government, thrust Mr Ahmed back to centre stage.
He led his group into negotiations with the government and in December 2008 President Abdullahi Yusuf Ahmed quit after a power-struggle with his prime minister about the reconciliation talks.
A month later Mr Ahmed and 150 of his fellow ARS members joined the Somali parliament and he was elected to succeed President Yusuf.
He says he wants to make peace with Ethiopia, recruit Islamist militia fighters into a national security force and rebuild the country's social services.
President Ahmed - who speaks English as well as Arabic and Somali - says he is prepared to discuss any political or religious issues with insurgents still fighting in Somalia.
Analysts say the polyglot will need all his skill with words to deal with the likes of the radical Islamist al-Shabab militiamen, who control swathes of central and southern Somalia.