Somalia’s MPs are due to elect the country’s president at the heavily guarded airport complex in Mogadishu, as the rest of the capital 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 seen as 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.
Over 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, 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 venue where the voting venue.
Residents in Arbacow village outside Mogadishu say jihadists 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.
Wednesday’s security measures include a ban on flights to and from Mogadishu airport.
Correspondents said most schools and offices remained open on Tuesday but people had had to walk to reach their destination.
Analysts say holding the election in the airport environment may also reduce the possibility of vote buying or other corruption in the election process.
- The aircraft hangar is crowded with MPs ready to vote