By Ulf Laessing and Feras Bosalum

TRIPOLI (Reuters) - Libya on Monday stopped a North Korean-flagged tanker that had loaded oil from a rebel-held port, after naval forces briefly exchanged fire with the rebels, officials said.

They also said the government will assemble forces to "liberate" all occupied ports, raising the stakes over a blockage that has cut off vital oil revenue.

The conflict over oil wealth is increasing fears that the OPEC producer may slide deeper into chaos or even splinter as the fragile government fails to rein in dozens of militias that helped oust Muammar Gaddafi in 2011 but now defy state authority.

The rebels, who have seized three ports and partly control a fourth in the North African country, said they had dispatched forces to central Libya to deal with any government attack.

Prime Minister Ali Zeidan told Reuters naval forces had seized the North Korean-flagged tanker outside the eastern Es Sider port controlled by rebels and were taking it to a government port in western Libya.

"The ship is around 20 miles from Es Sider," Zeidan said. "It stopped due to darkness and won't move tonight but is under complete control and secured. Tomorrow it will move."

Naval forces had halted the ship after a brief firefight with the rebels, Culture Minister and government spokesman Habib al-Amin later told reporters. Nobody had been wounded, but he warned opening fire again might damage nearby oil facilities.

A spokesman for the rebels denied several times throughout the evening that they had lost control of the ship.

Even without any major military action, the escalation kills any hope of restoring oil exports soon. A wave of protests at oilfields and ports has reduced Libyan output to a trickle, undermining state authority because oil is the main revenue source supporting the budget and basic food imports.

The head of parliament, who has quasi-presidential powers, ordered the formation of a force made up of regular soldiers and allied militias to take back the occupied ports, which previously handled more than 700,000 barrels of oil per day.

Story continues

The operation will start within one week, parliament head Nuri Ali Abu Sahmain said in a decree published by spokesman Omar Hmeidan. "The force will be set up to liberate the ports and end the blockage," Hmeidan told Reuters.

Zeidan, who said on Saturday the tanker would be bombed if it tried to export oil, said military action was only one of several options.

"What is confirmed it that all ports will be liberated from the occupiers with all means possible," he said. "We prefer talks but if talks fail then the state will act."

Zeidan said authorities would unload the crude from the tanker once it reached a western port and then launch legal measures against the potential buyers.

DEFIANT REBELS

Libya has been trying to rebuild its army since Gaddafi's ousting, but analysts say it is not yet a match for battle-hardened militias that fought in the eight-month uprising that toppled the dictator.

Still, the force will be drawn from cities such as Misrata that are home to fighters who saw battle in the civil war, according to the decree. Misrata forces were sent earlier this year to fight in clashes deep in Libya's south.

Abb-Rabbo al-Barassi, the self-declared rebel prime minister, called on "all honorable men" in the east to join his forces, a rebel television station reported.

The rebels, made up of former oil security guards, said they had sent forces by land and sea to central Libya to confront any government attackers.

FULL CONFRONTATION UNLIKELY

While the navy did open fire on a Maltese-flagged tanker trying to approach Es Sider in January, analysts say a full military confrontation with the rebels would be unlikely.

The protesters are led by a former anti-Gaddafi commander, Ibrahim Jathran, who was in charge of protecting oilfields and ports until he turned against the government in the summer.

Jathran's campaign to seek more rights for Libya's underdeveloped east has won him some sympathy, but many people dismiss him as a tribal warlord with no political vision.

Libya's top Islamic clerics urged militias who had helped topple Gaddafi to help the government in trying to stop the tanker, according to a statement read on television.

The United Nations' special envoy to Libya, Tarek Mitri, told the U.N. Security Council on Monday that the loading of oil onto the North Korean-flagged vessel "constitutes an illegal act and violates Libya's sovereignty over its ports and natural resources".

On Sunday, Tripoli said the navy and pro-government militias had sent boats to stop the 37,000-tonne tanker from leaving. The vessel had arrived at Es Sider on Saturday.

It is unusual for a tanker flagged to secretive North Korea to sail in the Mediterranean. Shipping sources said it was a flag of convenience to keep the ship's ownership secret.

In a rare bright spot, state National Oil Corp managed to restart the southern El Sharara oilfield after a protest ended there, a spokesman said. It is now pumping 150,000 barrels per day and might reach full capacity at 340,000 bpd by Tuesday afternoon.

(Additional reporting by Ayman al-Warfalli, Ghaith Shennib, and Michelle Nichols at the United Nations; Editing by Dale Hudson and Mohammad Zargham)