Gen. Khalifa Hifter during a March 2015 interview with the Associated Press in al-Marj, Libya. (Mohammed El-Sheikhy/AP)

He’s a grandfather and longtime Washington suburbanite who now commands a powerful fighting force in northern Africa. He’s also a former CIA asset and anti-Islamist warrior who stands in the way of peace in Libya.

The United States and its allies can’t figure out what to do about Khalifa Hifter, the Libyan general whose refusal to support a fragile unity government has jeopardized hopes for stability in a country plagued by conflict.

Since he emerged as an important post-revolution figure in 2014, Western governments have struggled to define an effective policy to deal with Hifter, who has styled himself as an antidote to extremists while building his own power base and shunning the political process brokered by the United Nations.

“Hifter is threatening many of the Western-backed initiatives in Libya and the establishment of a recognized political power,” said Barak Barfi, a scholar at New America, a Washington think tank. “Hifter doesn’t have the strength on the battlefield to deliver on his promises to defeat Islamists, but he can act as a spoiler.”

Even as militia forces, backed by U.S. air power, make progress against the Islamic State in central Libya, Hifter looms as a primary impediment to White House hopes for restoring the democratic promise of the 2011 revolution that ended dictator Moammar Gaddafi’s long rule.

Hifter’s role in a much earlier, CIA-backed attempt to overthrow Gaddafi injects another element of complexity into American efforts to end Libya’s long crisis.

A former senior U.S. official, who like others spoke on the condition of anonymity to discuss internal deliberations, said that Hifter’s connections across the Middle East and beyond have made it difficult for the Obama administration to develop a unified strategy to confront or co-opt him.

“Even if there had been unity of thought within the U.S. government, we didn’t have the capability to marginalize him and we also didn’t have the capacity to integrate him,” the official said. “He was this free electron.”

Hifter, who got to know Gaddafi as a young military officer, appeared to be a loyal follower of the Libyan leader until 1987, when he and 400 other troops were captured by opposing forces in neighboring Chad, where he served as a commander in the Libyan leader’s war there.

Hifter turned against his onetime patron when Gaddafi repudiated the failed campaign in Chad, along with the prisoners of war and Hifter himself. Hifter joined the National Front for the Salvation of Libya (NFSL), a U.S.-backed group of Libyan dissidents that was laying plans to topple Gaddafi.

President Ronald Reagan’s White House had previously approved a covert operation, code-named “Tulip,” that aimed to channel support to dissident groups with the goal of overthrowing the Libyan leader. Gaddafi had ties to terrorist groups and was allied with the Soviet Union. Reagan branded him “the mad dog of the Middle East.”

It was in Chad that Hifter’s men connected with U.S. intelligence agents, according to multiple former officials who were involved in the Libya operation.

According to one former official, the Libyan soldiers under Hifter were trained by personnel from the CIA’s Special Activities Division, the agency’s paramilitary arm. The CIA declined to comment.

The former official described Hifter as a tough, experienced soldier. “He’s a hardhead, but he’s a reasonable man,” he said.

The planned coup attempt went nowhere, and U.S. officials were forced to rescue the Libyans in 1990, when a new Chadian leader prepared to throw them out. The men were flown to Nigeria and then Zaire, but it soon became clear that no African leader wanted them.

“It was a long, sad history of trying to dispose of them and finding a place for them to live,” a former intelligence official said.

Six months later, a U.S. military aircraft flew about 350 Libyan rebels to the United States. Some of the rebels, including Hifter, continued to train with weapons in rural Virginia in anticipation of another coup attempt, according to Bechara Charbel, a journalist working for the pan-Arab newspaper Hayat who visited a training camp at the time.

Hifter, living in Northern Virginia, eventually split from the NFSL but remained active in dissident circles.

After Libyans rose up in 2011, Hifter returned to northern Africa but failed to secure the backing of interim leaders to head rebel military operations against Gaddafi. He came back to Virginia “to enjoy my grandchildren,” he told New Yorker magazine.

In February 2014, seemingly out of nowhere, the general released a video announcing a military coup. He railed against the inability of the then-central government to confront armed Islamist groups that had grown strong after the revolution.

At the State Department, officials scrambled to respond. “Everyone was like, ‘Is this a joke?’ ” one former State Department official said. “Because this guy had been living in Vienna forever,” referring to the suburb in Northern Virginia. The coup gained no traction, and the episode was widely derided.

Soon afterward, with support from tribal and political factions, Hifter launched “Operation Dignity,” a bid to clear eastern Libya of militant groups including Ansar al-Sharia, which was blamed for the 2012 attack on U.S. personnel in Benghazi. As Libya’s political crisis expanded, lawmakers in the eastern city of Tobruk named him their top military commander.

Hifter’s actions also won him favor from some ordinary Libyans desperate for a response to rampant crime and lawlessness.

“In the east, he is a hero . . . someone who was able to take initiative when [others] failed to do so,” said Mohamed Eljarh, a scholar with the Atlantic Council. “That is what won him trust, credibility and popularity.”

Col. Ahmed Mesmari, a spokesman for the forces that Hifter commands, said they had sacrificed thousands of troops but succeeded in weakening a range of militant groups.

But the campaign — which without a definitive military victory has left much of Benghazi in tatters and put civilians under threat — has also fueled divisions among Libyans. Hifter’s forces have clashed sporadically with groups now aligned with the U.S.-backed government.

In Tripoli and other parts of western Libya, some see Hifter as more dangerous than the Islamic State.

But the general has powerful allies, including the United Arab Emirates and Egypt, which have encouraged his campaign in the eastern part of the country. French troops have been using Benghazi’s Benina air base, where Hifter’s forces also operate. And although it is unclear what relationship he has with the French, he has benefited from the perception of outside backing.

Hifter has been compared favorably to Abdel Fatah al-Sissi, the general-turned-strongman president in Egypt who shares the Libyan’s desire to quash the region’s Islamists.

“He’s been able to parlay what I think has been uneven military performance into political leverage,” said Frederic Wehrey, an expert on Libya at the Carnegie Endowment for International Peace. “Regional support is a key factor.”

Like other top political leaders in the east, Hifter has refused to support the Tripoli-based unity government, as required under a U.N.-brokered political deal, until it secures the backing from lawmakers in the eastern city of Tobruk.

“Hifter is not interested in democracy,” the former State Department official said. “I don’t even think he’s particularly interested in peace.”

At the heart of the impasse is Hifter’s own future and plans by the new unity government that would strip the general of his command.

Mesmari denied that Hifter and those under him were interested in politics, saying they want to protect Libya from a new government that he said had ties to Islamist factions. “We are military men,” Mesmari said. “Our task is maintain the security in Libya.”

Hoping to signal support for the unity government, U.S. diplomats have steered clear of Hifter, but neither do they expect a future for Libya without him. U.S. officials now hope to build support for giving Hifter a regional military position in the unity government.

But it seems unlikely the general, seizing his chance so many years after Gaddafi abandoned him in Chad, would accept a subordinate job.

Last week, the U.N. envoy to Libya acknowledged that support for the unity government, mired in infighting, is slipping away, threatening to collapse the Western project in Libya and creating the prospect of indefinite civil conflict and terrorist activity.

That may help the general, Eljarh said, as he consolidates his position and continues to portray himself as the only man who can save Libya.

“Hifter feeds on the failure of governance, the failure of initiative and the failure of the international community to come up with solutions that are workable,” he said.

Adam Goldman contributed to this report.