The White House said on Friday that US President Donald Trump had been in direct communication with eastern Libyan commander Khalifa Haftar earlier this week.
During a readout call with media, a White House spokesperson said Trump had discussed "ongoing counterterrorism efforts" with Haftar over the phone on Monday.
It was unclear why the White House waited several days to announce the phone call.
The White House spokesperson said Trump "recognised Field Marshal Haftar’s significant role in fighting terrorism and securing Libya’s oil resources," adding that Trump and Haftar "discussed a shared vision for Libya’s transition to a stable, democratic political system".
Later on Friday, acting US Defense Secretary Patrick Shanahan said "a military solution is not what Libya needs," Reuters news agency reported.
He said he supported Haftar's "role in counterterrorism" and that Washington needed Haftar's "support in building democratic stability there in the region."
Asked whether Trump contacted him before calling Haftar, Shanahan said the Pentagon and the White House "are well-aligned on Libya."
Haftar, the leader of the Libyan National Army (LNA), launched an offensive earlier this month to take the Libyan capital, in opposition to the country's internationally recognised government.
A spokesperson for the LNA latter applauded Trump's statements, saying his remarks show that the US believes in the pivotal role of Haftar's forces in the war against terrorism, Sky News Arabia reported.
The news of Trump's call with the LNA leader comes one day after the US and Russia said neither country could support a United Nations Security Council resolution calling for a ceasefire in Libya - an apparent turn in US foreign policy.
Some UN diplomats have suggested the US might be trying to buy time as Trump's administration works out how to deal with the latest developments in Libya.
"I think there are a range of views in Washington on the policy side and they haven't reconciled them and they're not entirely certain where the president is on it," a senior UN diplomat, speaking on condition of anonymity, told Reuters on Thursday.
"The American system is trying to evaluate all the scenarios and work out which one is in America's best interest and just hasn't done that yet," the diplomat said.
While Friday's White House statement made no mention of Haftar's offensive on Tripoli, the move signals a change in the Trump administration's policy on the issue.
Last week, French Foreign Minister Jean-Yves Le Drian spoke with US Secretary of State Mike Pompeo about Libya and both agreed on the need for a "rapid" ceasefire and return to the UN-led political process, the French foreign ministry said in a statement.
Earlier this month, Pompeo said the US had "made clear that we oppose the military offensive by Khalifa Haftar's forces", while urging "the immediate halt" to the LNA's offensive on the capital.
"This unilateral military campaign against Tripoli is endangering civilians and undermining prospects for a better future for all Libyans," he added.
LNA's ongoing offensive
In Tripoli on Friday, shelling could be heard in southern parts of the city as in previous days, residents told Reuters.
Nearly two weeks into its assault, the eastern-based LNA is stuck in the city's southern outskirts, battling armed groups loyal to the internationally recognised Tripoli government lead by Prime Minister Fayez al-Serraj.
Forces allied to Tripoli have accused the LNA of firing rockets into residential areas, but Haftar's army said in a statement it was not behind the late night shelling.
Haftar enjoys the backing of Egypt, the United Arab Emirates and Saudi Arabia, which view him as an anchor to restore stability and combat militants in Libya, while most Western powers have supported the government of Serraj.
Trump met with Egyptian President Abdel Fattah al-Sisi on 9 April.
Libya has been gripped by anarchy since Muammar Gaddafi was toppled in 2011.
Although Haftar was one of the officers who helped Gaddafi rise to power in 1969, relations soured during Libya's war with Chad in the 1980s.
Later Haftar came to live in the US, where he stayed for around 20 years before returning home in 2011 to join other rebels in the uprising that ousted Gaddafi.