The United Nations has failed to mediate a peace deal between Yemen's Houthi rebels and the government, as Shia fighters advanced into the capital in an escalation of violence that has brought the country to the verge of a civil war.

The UN envoy to Yemen, Jamal Benomar, left the northern city of Saada on Friday after trying to mediate a deal that could pave the way for a new government and more political representation for the Houthis.

Fighting between rebels and government troops continued for a second day in the capital Sanaa on Friday as war planes flew over the city, with the warring sides attacking each other a kilometre from the presidential palace compound.

Clashes had raged on the outskirts of Sanaa for days, with dozens of deaths reported.

Al Jazeera's Hashem Ahelbarra, who has been following developments in the country for years, said the country is "just a few hours" from plunging into a civil war as the capital city is divided along sectarian lines, with one half run by Sunnis and the other by Houthis.

"The Houthis have control over most of the north of the country - from Saada to the gates of Sanaa. They have thousands of fighters and some military commanders and members of the former regime with them - and if in the coming hours they decide to control Sanaa, they can definitely control the capital," Ahelbarra said.

"If the Sunnis decide to join the fight against the Houthis, it's definitely going to be civil war in the country [...] It's either peace or war."

The Houthis are a Shia movement whose traditional power base is in the north. They are demanding a new government and also more political power for their community.

Thousands of Houthis have been staging protests in Sanaa for more than a month, besieging ministries and blocking the road to the main airport.

Local officials said on Friday that hundreds of residents were forced to flee their homes after the Houthi rebels shelled Yemen's state television offices in Sanaa as they pushed into the capital.

Fighting in the capital had become so intense that, by Friday, international airlines suspended flights in and out of the nearby airport.

The government's plans for a six-region federation in Yemen to address the grievances of the regions has been rejected by both the Shia rebels and southern separatists.

ANALYSIS FROM OUR CORRESPONDENT

The UN was trying to mediate a deal which included the Houthis demands of the formation a new government of technocrats, a reduction in fuel prices and giving Houthis more political representation. In exchange, the Houthis would have had to pull out of Sanaa and put an end to their civil disobedience campaign.

President Abd-Rabbu Mansour Hadi faces a tough choice: he is from the south and northern Yemen is not his power base. Most of the army’s top military commanders are Shias and he is worried they might defy his orders if he calls for war.

On the other hand, there is a growing frustration among the Sunnis. They say Hadi is weak, and that under his tenure more territory was lost to the Houthis. If the Shia rebels control Sanaa, Sunni tribes might call for his resignation.

And if fighting breaks out in Sanaa, a city divided along sectarian lines and armed to the teeth, it might be the worst on the Arabian Peninsula in modern history.

Explaining Yemen's political-military groups:

Houthis - Shia group also known as Ansarullah, or "Partisans of God", who have been at war with the government since 2004. They demand resignation of government, more political inclusion and access to the sea. Strongholds include Saada, al-Jawf and the Jeraf district inside Sanaa.

Al-Islah (Reform) - Sunni Islamist party that draws support and membership from heavily armed Sunni tribesmen, and is instrumental in rallying support behind the army and the government. Present in almost all of Yemen. The Houthis have identified the party as its arch-enemy.

Al-Qaeda in the Arabian Peninsula - A merger of the Yemeni and Saudi branches of al-Qaeda. Seized large swathes of territory in the south and the southeast after the uprising in 2011. Launched many attacks on armed forces and central authority establishments. Its power bases are Shabwah, Abyan and Hadramawt.

The Southern Separatist Movement - Umbrella group that wants the south to break away from the north and reinstate the former Socialist state that existed until 1990. Led by Ali al-Beidh.