(CNN) -- Somali lawmakers are scheduled to choose the next president Monday, moving the nation a step closer to its first stable central government since the 1991 ouster of a dictator.
The new parliament, which was selected last month, will hold a ballot to choose the president from about two dozen candidates.
In a letter to lawmakers, the United Nations called for a credible leader who can propel the African nation toward peace.
"After two decades of civil war, a collapsed state and innumerable indignities to the proud Somali people, we are hours away from the election of a new president," said Augustine P. Mahiga, the U.N. envoy to the nation.
"The event that will completely end the transitional period and move us toward a phase of political and socio-economic transformation."
The scheduled vote is the latest in a series of political transitions in the nation.
In recent weeks, it has adopted a provisional constitution, held an inaugural meeting of its new parliament and appointed that body's speaker.
"It has not been easy getting us to this point," Mahiga said. "There have been moments when all seemed lost and we have sometimes been on the brink of despair."
Candidates include incumbent President Sharif Sheikh Ahmed, who has been in power since 2009, and his prime minister, Abdiweli Mohamed Ali.
Dictator Mohamed Siad Barre was overthrown 21 years ago, sparking years of warring militias and a transitional government that has remained shaky at best. Over the years, lawmakers have met in neighboring Kenya and Djibouti because of a lack of security in Somalia.
"It is the first time Somali politicians are choosing a new leader for the country on home soil," said Hamza Mohamed, a Somali analyst based in London. "Previous elections were held in Djibouti and Kenya. Because of this, Somalis feel they're part of the process this time even though they're not voting in the president."
The temporary nature of a transitional government made the next leader a guessing game.
"This election will end the uncertainties of who will be president," Mohamed said. "They (Somalis) will know who will be running their country for the next four years."
The new leader will need two-thirds of the vote from the 275-member parliament. Failure to get the vote will send the top four candidates to a second round of voting, according to the analyst.
Despite the move toward a more permanent government, challenges remain. Large swaths of the country are under militants' control, and assassinations and roadside bombs are common in Mogadishu.
And even though insurgents have fled the capital and guns have fallen silent, the years of war have been divisive.
"There needs to be reconciliation between the clans that have spent the best part of the last 20 years fighting each other," Mohamed said.
In addition to the peace process, cracking down on militants nationwide remains elusive.
African Union and Somali troops are battling Al-Shabaab militants, an al Qaeda-linked group that controls part of the nation's south.
In recent months, the troops have driven the militants out of Mogadishu, and the capital is slowly trickling back to normalcy. Coalition forces are exerting control in more areas, but it is not secure enough to hold a nationwide vote.
The militant Islamist group has waged an insurgency against the weak transitional government since 2007.