Somalia’s MPs are electing the country’s president in a heavily guarded aircraft hangar in Mogadishu, as the rest of the country is not safe.
Traffic has been banned, schools have been shut and a no-fly zone imposed over Mogadishu to prevent attacks.
Despite this, suspected militant Islamists fired mortar rounds close to the venue on Tuesday night.
Somalia, marred by religious and clan conflict, 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.
The elections are part of a lengthy and complex process to help the East African state rebuild its democracy and achieve stability.
More than 20,000 African Union (AU) troops are stationed in Somalia to prevent militant Islamist group al-Shabab from overthrowing the weak government.
About 20 candidates are vying to become president, with the top three proceeding to a second round of voting and the top two from that round going forward to a third and final vote.
The election hall is a converted aircraft hangar at the fortified airport complex, and is packed with MPs, reports the BBC’s Ferdinand Omondi from the venue.
President Hassan Sheikh Mohamud is standing for re-election and analysts say he is likely to be one of those who goes forward to the later rounds.
The airport is viewed as the most secure site and voting was moved there from a police academy because of growing security concerns.
On Tuesday evening, suspected al-Shabab militants launched a series of attacks, with two mortar rounds fired close to the voting venue.
Residents in Arbacow village outside Mogadishu say militants attacked an AU base there.
Al-Shabab has a presence in much of the southern third of the country and has previously attacked the Somali parliament, presidential palace, courts, hotels and the fortified airport zone.
At least 19 politicians, as well as many civilians and soldiers, have been killed in its assaults.