Election campaigns are a novelty in Somalia
Somalia's parliament has started choosing a new president, in the latest step to end decades of war.
The newly elected MPs have convened at a police academy in Mogadishu for the secret ballot.
The process began five hours late, following tight security checks and a wrangle about whether to let former warlords vote.
It is the first time in many years that a president will be chosen on Somali soil - a sign of improving security.
However, the al-Qaeda linked group, al-Shabab, still controls many southern and central parts of the country, and has staged frequent suicide attacks in the capital since it was driven out of Mogadishu last year by African Union troops and pro-government forces.
Current Islamist President Sheikh Sharif Sheikh Ahmed, in power since 2009, is regarded as one of the favourites among the 22 candidates.
The president's opponents have accused him of corruption - a charge he has repeatedly denied.
There is a mood of real excitement and anticipation in the city, and the election is being broadcast live on several local TV stations.
There are reports that parliamentary accreditation cards are being sold for $20 (£12) but this has not affected the security process, which is being carried out at the airport, where the African Union has a large military base.
After being approved, the MPs then travelled a few kilometres to the police academy along a road which has been closed to non-official business and which is being closely guarded.
The election was also delayed by the swearing-in of the last batch of MPs and then a vote on whether a group of disputed MPs, including former warlords, could take part.
Outgoing Prime Minister Abdiweli Mohamed Ali is seen as one of his strongest challengers, along with former Prime Minister Mohamed Abdullah Farmajo.
All the candidates are men and they also include several former ministers, academics and moderate Islamists.
Analysts say the election is likely to be decided by the clan structure, which remains a huge factor in Somali life. However there are also reports of votes being sold.
The BBC's Daud Aweis in Mogadishu describes a mood of real excitement in the city. The election is being broadcast live on several local TV stations, and is being streamed live on an official feed.
As well as the tight security checks, the election was also delayed by the swearing-in of the last batch of MPs and then a vote on whether a group of disputed MPs, including former warlords, could take part. The MPs voted in favour.
To win in the first round of voting, a candidate needs to secure a two-thirds majority.
If no candidate achieves that, the four best-placed candidates go through to a second round, when again a two-thirds majority is needed.
If needed, the two best-placed candidates would then go to a run-off.
The new speaker of parliament, Mohamed Osman Jawari, has urged MPs to vote with their consciences.
"May God help us to elect a good leader in an atmosphere of tranquillity. We must give the youth of Somalia a bright future," he said.
The process is still in many ways owned by outside powers who have for years been involved militarily and politically in Somalia, the BBC's Mary Harper reports.
She says that it is telling that in recent days the UN, the African Union, the US, Britain and others have issued strong statements on Somalia, some warning that resorting to violence is not an option.
They have invested so much money, time and manpower in trying to solve the Somali problem that they cannot afford to see it fail, our correspondent adds.
Since the overthrow of President Siad Barre in 1991, Somalia has seen clan-based warlords, Islamist militants and its neighbours all battling for control.