Eastern Libyan commander Khalifa Haftar ordered his troops to "advance" on the capital Tripoli in a video message published after UN Secretary-General Antonio Guterres warned of the growing risk of violence.

Haftar gave his orders in a video posted online on Thursday, hours after his forces took full control of Gharyan, a town about 100km from Tripoli.

"The time has come," Haftar said in a video titled 'Operation to liberate Tripoli'.

"To our army which is stationed at the outskirts of Tripoli. Today we complete our march ... We are going to start shortly."

Haftar's self-proclaimed Libyan National Army (LNA) had announced a day earlier that it was gearing up to move on the west of the country, including the capital, home to a UN-backed unity government.

Spokesman Ahmed Mesmari said preparations were almost complete "to purge the west of terrorists and mercenaries".

'Taking Tripoli is certainly not an easy or risk-free task, but it's still a possibility'

- Jalel Harchaoui, Clingendael Institute

His statement was followed by troop movements on the ground, local and military sources said, as a convoy of LNA vehicles approached Gharyan.

Commander Abdessalem Al-Hassi told AFP news agency on Thursday that his forces had entered into the city without fighting.

But at least four sources AFP spoke to in Gharyan denied Hassi's claim, and a local official said there were "ongoing efforts to avoid a confrontation" between rival fighters who divide the city.

The rise in tensions came as Guterres visited Tripoli ahead of a planned conference later this month to hammer out a roadmap for delayed parliamentary and presidential elections.

"I am deeply concerned by the military movement taking place in Libya and the risk of confrontation," the visiting UN chief tweeted from the capital.

"There is no military solution" to Libya's woes, he added.

'Stop the cursed advance'

Dozens of militias have fought for control of the North African country since a NATO-backed uprising toppled and killed longtime leader Muammar Gaddafi in 2011.

Haftar's forces have emerged as key operators, opposing the government in Tripoli and backing a parallel administration in the east.

Hoping for peace, preparing for war: Libya on brink of Tripoli showdown

The Tripoli government relies on a patchwork of armed groups with often changing loyalties.

Unity government chief Fayez al-Sarraj condemned Haftar's "escalation" and said he had ordered pro-government forces to prepare for a potential military confrontation.

Powerful armed groups from Libya's western city of Misrata, which back Sarraj, said they "stand ready... to stop the cursed advance".

The European Union warned that the "military buildup underway in Libya and the escalatory rhetoric... seriously risks leading to an uncontrollable confrontation".

The United States and its allies on Thursday called for an immediate de-escalation of tensions and warned of consequences of military action.

"Our governments oppose any military action in Libya and will hold accountable any Libyan faction that precipitates further civil conflict," said a joint statement by the United States, France, Britain, Italy and the United Arab Emirates.

A Qatari Foreign Ministry spokeswoman warned that the behaviour of Haftar's forces in western Libya will threaten regional security, Al Jazeera Arabic reported on Twitter.

The spokeswoman also called on the countries that had issued a joint statement expressing "concern" about the situation in Libya to "rein in" Haftar's fighters, expressing bewilderment that Abu Dhabi is calling for calm while supporting the Libyan general.

'The risk of conflagration has increased'

Rival leaders had agreed in Paris last year to hold elections before the end of 2018, but that vote never materialised as Haftar's forces and the Tripoli government grappled for power.

The UN said Haftar - who enjoys the backing of Egypt and the United Arab Emirates - and Sarraj agreed at a meeting in Abu Dhabi last month to make a new attempt to organise an election.

Libyan analyst Emad Badi said factions in western Libya were angling for a joint front against the rival government, but "whatever the result... Haftar will benefit from it militarily or politically".

"His progress can enhance his position in the negotiations", if the UN-backed conference set for this month goes ahead, he added.

Jalel Harchaoui, a researcher at the Clingendael Institute in The Hague, said that "taking Tripoli is certainly not an easy or risk-free task, but it's still a possibility."

"The risk of conflagration has increased," he said.

Some of Haftar's supporters have called the UN efforts a waste of time, urging him to carry out a military solution to establish himself as national army commander.