Libya has emerged from its civil war with more than 300 militias and no political consensus on forming a national army, raising concerns that irregular, gun-toting groups could become entrenched and pose a long-term challenge to the government, officials here said.

On Monday, Libyan leaders began to establish a new interim government with the authority to create the armed forces, choosing the technocratic Abdurrahim el-Keib as prime minister. But the militiamen who won the eight-month war have made it clear that they will not submit meekly to the new civilian authorities.

“Creating a new army is not going to be by an official statement or resolution. It has to come after a negotiation,” said Anis Sharif, a spokesman for Abdulhakim Belhadj, an Islamist seen as the dominant militia leader in Tripoli.

Reining in the militias is crucial to restoring order after the fighting between NATO-backed revolutionaries and loyalists of longtime dictator Moammar Gaddafi, diplomats say. NATO officially ended its operations in Libya on Monday night, giving the country full responsibility for its own security.

Although many of the fighters have been in a celebratory mood since the war ended, several confrontations between rival militias have threatened to escalate into bloodshed — including one at Tripoli’s airport Monday.

“The danger is that you have young men returning from battle, bored and with a newfound sense of regional identity and personal pride,” said a Western official in Tripoli, who was not authorized to comment on the record.

Militia and military leaders recognize the need to demobilize or integrate fighters into the security services, the official said. “But the key will be agreeing and implementing a plan to do this.”

‘A political vacuum’

Efforts to relaunch the army have been hobbled by the central government’s weakness and rivalries among revolutionaries.

Sharif said that one of the main goals of the Transitional National Council was to avoid a political vacuum.

“On this point, they failed — and failed completely,” he said, recalling that many of the council’s members remained in the eastern city of Benghazi, the bastion of the revolution, after Gaddafi’s forces were driven from Tripoli in August. “They left the capital with a political vacuum,” he said, and militias from other areas have moved in and set up camp.

Islamist fighters have squabbled with revolutionaries who once belonged to the national army over who should lead Libya’s new armed forces, so the top post is vacant, officials said. The military’s No. 2 officer — Deputy Chief of Staff Suleiman Mahmoud al-Obeidi — was stunned last month when a militia from the western Zintan region seized control of his Tripoli base while he was out of town, his aides said.

In response, Obeidi summoned about 700 heavily armed revolutionaries and threatened to wrest back control of the base, an old army supply headquarters in western Tripoli, said his son and legal adviser, Haytham al-Obeidi.

“It could have been a real confrontation. We were very, very angry,” the younger Obeidi said. The crisis was defused only when President Mustafa Abdel Jalil intervened, he said.

Haytham al-Obeidi said there were tensions between fighters from eastern Libya, where army officers such as his father defected en masse, and those from the west, many of them irregulars who took on Gaddafi’s military, risking torture and death.

Another confrontation occurred Monday evening at Tripoli’s military airport, where revolutionaries from eastern Libya pulled their guns on the crew of a military aircraft to try to get it to fly them to Benghazi, said Tripoli militia members who guard the facility. The group from the east was arrested, they said.

Human rights concerns

The lack of a unified Libyan military and police force has alarmed human rights activists, who say militias are meting out justice on an ad hoc basis to the country’s roughly 7,000 political prisoners, sometimes resorting to torture. At least 100 militias are operating in the city of Misurata, which suffered a bloody siege during the war, and more than 150 are in Tripoli, Western officials said. There are dozens more in Benghazi.

The cities have established councils to oversee the armed groups, but the degree of organization is limited.

Sadiq Turki, a revolutionary who is director of a military hospital in Tripoli, told a reporter that all of his militia members had ID cards and had to register their weapons.

“It’s forbidden to fire in the streets,” said Turki, wearing a black T-shirt and camouflage pants. “Even my bullets, we do an inventory. Someone comes every few days and counts.”

But moments after he spoke, someone with a semiautomatic rifle let loose with a rat-tat-tat-tat-tat-tat-tat in the hospital garden, apparently firing in the air for fun. “Who’s shooting? Who’s shooting?” Turki demanded.

Militias possess not only rifles, but also antiaircraft guns, rocket launchers and other heavy weapons.

“In the future, we’ll give them up to the military — when we have a military,” said Ashraf Jibril, 32, a jeans-clad revolutionary guarding the military airport. But the military can exert control only if the armed militias abandon their weapons, diplomats say.

Sharif said militia leaders are trying to form an umbrella group to negotiate with the government on the new military. A chief demand, he said, is that longtime Gaddafi allies who changed sides during the revolution not get top jobs.

“We don’t want, after all this sacrifice . . . to see the same old faces in charge again,” he said.

Diplomats say they expect Belhadj, who played a key role in the revolution, to seek senior Defense Ministry posts for his allies. That has caused some unease among Western officials, since Belhadj belonged to the Libyan Islamic Fighting Group, which was listed by the State Department as a terrorist organization. Belhadj has said he did not support al-Qaeda, as some members of the group did.

Under Gaddafi, Libya had an elite military force of about 25,000, plus a roughly equal number of low-paid, poorly equipped conscripts and officers. A vast group of young men with little military experience joined the revolution — doctors, students, used-car salesmen and others. Many seem to want to stay, in part because the economy has slowed to a crawl.

A Defense Ministry spokesman, Col. Ahmed Bani, said that all qualified revolutionaries would be welcome in the new armed forces of the oil-rich country. “We have enough money, we have enough jobs for them,” he said.

Several militia members said they would be willing to return to civilian life if ordered to do so. But some seem to be settling in for the long haul.

Jibril, who was a dentist before the revolution, showed a reporter a former hotel near the military airport that is being converted into a headquarters for his men. It had an office with a conference table that seats 25.

“We’ll make a cafe here, for coffee and tea,” he said, showing off a bar.

So was he planning to stay for a while?

“I think so,” he said. “Because of the security of the country. We can’t count on the old police. Most of them were with Gaddafi.”