MOGADISHU, Somalia — Somalia’s lawmakers met in a low-ceilinged basement, below the bombed-out, roofless shell of the old chamber, guarded by African Union soldiers.

Set on a hill, Somalia's parliament looks out to the sparkling Indian Ocean beyond the once-grand neighborhood of Hamar Weyne, with its ruined cathedral and broad boulevards.

On the other side is a statueless plinth, an avenue of gnarled and twisted trees beneath which tea shops have opened up in recent months. A squatter camp — thousands of small, rag-covered stick domes crammed together in the mile-long depression — stretches towards the copse of skyscrapers marking Bakara Market.

The parliament building — ringed with razor wire, sandbags, and soldiers — enjoys a commanding position, but its occupants do not.

Even as the combination of African Union, Somali, Ethiopian and Kenyan forces (with the occasional assistance of a US drone strike) erode the military strength of the militant Islamist group Al Shabaab, Somalia’s politicians are squandering the opportunity that this rare moment of peace and stability in Mogadishu offers.

A dispute erupted in mid-December when a gang of lawmakers held a vote to oust the speaker, Sharif Hassan Sheikh Adan, claiming a majority of the 550 MPs. A powerful businessman and wily political operator, Adan and his loyalists claimed that the elections were fraudulent and refused to recognize the ballot, as did President Sheikh Sharif Ahmed and his backers in the international community, who do not want to see yet another transitional government collapse.

So now there are, in effect, two parliaments and two speakers. The opposing factions barely talk to each other. When they have come face to face in parliament there have been fistfights so serious that they have resulted in hospitalizations. The crisis is proving as intractable as it is unseemly.

The man tasked with solving the stalemate is Augustine Mahiga, a Tanzanian diplomat and UN Secretary-General Ban Ki-moon’s top official in charge of Somalia.

Until last week, Mahiga was based in Nairobi, where the UN Political Office for Somalia (UNPOS), which he runs, has been headquartered since its inception 16 years ago. Now he lives in Mogadishu along with a dozen or so of his staff, who work on rotations.

Of the 194 states in the UN, Somalia was the only one considered so unsafe and dysfunctional that it did not have a representative of the Secretary-General living in the country.

“I am here to bring the UN office for Somalia to Somalia,” Mahiga said on his first day in the capital.

Improvements in security since mid-2011 has made Mahiga’s move possible. “This could not have happened 10 months ago,” he said.

More from GlobalPost: Inside Somalia: Order restored in Mogadishu

Security has enabled Mahiga’s presence, but his job is still a tricky one. At a brief ceremony held in a dimly lit conference room President Ahmed sat at the head of a vast shiny table, Speaker Adan at his right hand.

“We have a semblance of a political framework in place that brings together diverse political groups, and my being here means I can have day-to-day meetings addressing issues face-to-face, not over the phone,” Mahiga told GlobalPost.

At the top of the agenda was solving the parliamentary impasse.

Mahiga denies this will derail the fragile political process but concedes it might, “complicate and delay” the so-called "Roadmap," a document agreed upon last September which sets an August 2012 deadline for a new constitution, new parliament and new government. It is supposed to transform the current transitional government, which President Sharif heads, into a proper one.

“For the first time in 21 years, we are so close to ending the transition,” Mahiga said.

There will not be an election, at least not in the sense of a national vote; that is beyond the dreams of even the wildest optimist after more than two decades without a government.

Instead, an electoral college of traditional clan elders will be chosen, which will, in turn, select a slimmed down parliament which will then vote for a president who will appoint a government.

All of this is due to happen by August, and it looks as if it’s going to be a long six months.

“There are many vested interests in maintaining the status quo after 20-years of civil war,” said Mahiga.

Back in parliament, the other Speaker, Madobe Munow Mohamed, was directing affairs, addressing a hall where only his supporters were present: 278 parliamentarians whom he claims voted Adan out and him in.

The ballot was not independently verified — there are allegations of duplicate voting — and has not been recognized, but it has been enough to stall progress.

Related: Somalia parliament fights again (VIDEO)

Among the parliamentarians that day was Mohamed Abdi Yusuf, a former prime minister, who said, “We sacked the former speaker because he failed to abide by the rules of parliament.”

He and others complained that Adan did not bring bills to parliament for debate and, rather, used his influential position to advance his business interests. “We were being cut out,” said Hassan Warsame, a parliamentarian.

Mahiga’s proffered solution was a re-run of the vote of confidence in Speaker Adan, who agreed to stand aside if he lost. However, this compromise was rejected by the anti-Adan faction, leaving Mahiga frustrated.

“There was no issue that they wanted to raise, they just want to get rid of the Speaker. That’s all,” he told GlobalPost afterwards.

Friction between the legislature and the executive is longstanding with each trying to exert authority over the other. Parliament has forced the dismissal of presidents, prime ministers and government in the past.

With a possible end to Somalia’s long and tortured transition in sight, and with Al Shabaab on the backfoot, Mahiga and others in the international community do not want to see yet another initiative collapse.

But after two days in his new home, Mahiga left without a deal for regional and continent-wide summits in Addis Ababa. He said he would continue negotiations when he returns.

More from GlobalPost: Inside Somalia - In Depth Report

Video: fights break out among Somali lawmakers: