Guterres was deeply concerned after the meeting with Haftar who had ordered his self-proclaimed Libyan National Army (LNA) and allied troops to march on Tripoli.
The sides have been in an uneasy truce since shortly after Gaddafi's downfall but the country now risks falling into civil war.
"We urge all involved parties to immediately halt all military activity and movements toward Tripoli", the body, which is composed of the foreign ministers of Canada, France, Germany, Italy, Japan, the United Kingdom and the USA wrote in a statement.
The U.N. Security Council on Saturday called on Haftar forces to halt all military movements and urged all forces in Libya "to de-escalate and halt military activity".
The head of Libya's internationally-recognised government, Fayez al Sarraj, on Saturday accused his rival Khalifa Haftar of "betraying" him after the military strongman launched an offensive against the capital Tripoli.
Italy's foreign minister said Haftar must listen to warnings from the worldwide community to halt his advance on Tripoli.
On Friday, Haftar's forces were pushed back from a key checkpoint west of the capital, less than 24 hours after seizing it during the lightning offensive towards Tripoli.
Haftar's campaign to impose stability through military force has won him some support from Libyans tired after years of war and political stalemate, the Wall Street Journal said.
Militias from the western cities of Zawiya and Misrata, which control Tripoli, said they had mobilised to confront Haftar.
Tesla Announces Big Miss on First Quarter Car Deliveries
JPM was almost spot-on with estimated vehicles in transit, however, estimating 10,000 vehicles were still tied-up in logistics. The firm blamed problems with shipments to Europe and China, where it began selling its Model 3 vehicle for the first time.
Lavrov said Russian Federation wanted all political forces in Libya to find an agreement and warned against foreign meddling there. The LNA controls the East of Libya, running a parallel administration to that of the Tripoli government.
After meeting with Haftar in the eastern city of Benghazi, Guterres said he was leaving "Libya with a deep concern and a heavy heart" and voiced hope that a "bloody confrontation" could be avoided.
At least one armed group from Misrata - whose forces are mostly loyal to the UN-backed government - arrived on Saturday in east Tripoli to join the counter-offensive, according to an AFP photographer.
UN Secretary-General Antonio Guterres during his visit to Ain Zara Detention center in Tripoli, Libya.
A G7 communique said that "we recall that Libya's oil facilities, production, and revenues belong to the Libyan people, and must not be used by any party for political gain".
Analysts say the advance by Haftar's forces comes at a key moment as the United Nations bids to get elections back on track after an abortive effort a year ago.
Hifter's forces were stopped from advancing, and about 100 of his fighters were captured by the pro-government militias, local media reports said.
The EU, for instance, is making strenuous efforts to ensure that the U.S. is seen to be telling Haftar to back off, and to tell his three principle external supporters - Egypt, Saudi Arabia and the United Arab Emirates - to do the same.