A 2011 photo shows buildings ravaged by fighting in Sirte, Libya, an Islamic State stronghold. U.S. Special Operations troops have established outposts in Libya to build relations with Libyan forces moving on Sirte. (Manu Brabo/AP)

American Special Operations troops have been stationed at two outposts in eastern and western Libya since late 2015, tasked with lining up local partners in advance of a possible offensive against the Islamic State, U.S. officials said.

Two teams totaling fewer than 25 troops are operating from around the cities of Misurata and Benghazi to identify potential ­allies among local armed factions and gather intelligence on threats, according to the officials, who spoke on the condition of anonymity to discuss a sensitive mission overseas.

The insertion of a tiny group of U.S. personnel into a country rife with militant threats reflects the Obama administration’s worries about the Islamic State’s powerful Libyan branch and the widespread expectations of an expanded campaign against it. For months, the Pentagon has been developing plans for potential action against the group, which has at least several thousand fighters in the coastal city of Sirte and other areas. And the U.S. personnel, whose ongoing presence had not been previously reported, is a sign of the acceleration toward another military campaign in Libya.

The mission is also an illustration of President Obama’s reliance on elite units to advance counterterrorism goals in low-visibility operations.

The activities of the American “contact teams,” as they are known, take place in parallel to those of elite allied forces from France and other European nations in the same areas, U.S. and Libyan officials said.

A member of the Libyan security forces displays part of a document in Arabic describing weaponry. It was found at the site of U.S. airstrikes on an Islamic State camp that killed dozens near the western city of Sabratha in February. (Mohamed Ben Khalifa/AP)

Officials hope the special operators will ultimately have an outsize impact on the effectiveness of local forces. Special Operations forces in Syria, for instance, have been trying to guide opposition operations and help them capi­tal­ize on foreign air power as they advance on the Islamic State.

“These types of activities can be the difference between success and failure in what the administration refers to as areas outside of active hostilities,” said William F. Wechsler, who was a senior Pentagon official overseeing Special Operations activities until last year. “You’re mapping local networks, both friendly and unfriendly.”

[Outside the wire: How U.S. Special Operations troops secretly help foreign forces target terrorists ]

The U.S. troops, who began making visits to Libya last spring and established their twin outposts six months later, have been cultivating relationships among forces that are mobilizing for a possible assault against the Islamic State in its Sirte stronghold.

Pentagon spokesman Peter Cook declined to provide specific information about the U.S. assessment teams. But he said that military personnel had been meeting periodically with a variety of Libyans “in an effort to help them reestablish a safe and secure environment.” The effort is part of a larger Obama administration strategy to bring Libya’s feuding factions together behind a fragile new unity government, which officials believe is best positioned to combat the Islamic State.

In Libya, a key element of the mission is identifying which factions will align themselves with the unity government. Since a civil conflict erupted in 2014, Libya has been dominated by two rival governments in the country’s east and west. The Obama administration and its European allies are hoping the unity government, installed after U.N.-brokered peace talks, can end Libya’s partition, which opened the door to extremists and plunged the oil-rich country into economic crisis.

The troops also are assessing security conditions so that, if a broader mission takes place, the United States can move in additional personnel more safely.

“How do you avoid Libya becoming like Syria?” said Paul Scharre, a former Army Ranger and Defense Department official who is now at the Center for a New American Security. “This is one of the tools in your toolbox to stave that off.”

[In Libya, the Islamic State’s black banner rises by the Mediterranean]

Although the Islamic State is far smaller in Libya than its parent organization in Iraq and Syria, the group has used similar tactics to enforce its brutal version of Islam, including mass executions, and has launched attacks across the North African nation.

“We’re obviously watching the threats very closely,” a senior administration official said, also speaking on the condition of anonymity.

If the White House does authorize a broader campaign in Libya, it is expected to be on a smaller scale than operations in Iraq and Syria. Apart from its ongoing air campaign against the Islamic State, the United States has more than 5,000 troops on the ground in Iraq, and Obama ­recently expanded the Special Operations force in Syria.

The United States has launched two airstrikes against Islamic State targets in Libya since late 2015, but Pentagon officials have said they have identified dozens of other targets that might be hit if a more sustained operation takes place.

An expanded mission in Libya will be forced to grapple with the same internal divisions that have undermined other foreign attempts to foster stability since 2011. In an illustration of those tribal and political fissures, the two forces preparing to advance on the Islamic State — militia forces loyal to Misurata and army troops under Gen. Khalifa Hifter — have clashed with each other.

The Misuratan forces recognize the unity government in Tripoli; those loyal to Hifter do not. Likewise, three factions have established separate command centers to oversee an offensive against the Islamic State in Sirte, including Hifter; the unity government; and an alternate prime minister in Tripoli, who continues to assert his authority.

American officials fear that uncoordinated offensives will only afford the Islamic State an opportunity to grow stronger.

At the same time, some officials privately complain that foreign support for eastern forces loyal to Hifter — including from U.S. ­allies France and Egypt — makes consolidation of the unity government’s power more difficult.

“We have been working with our allies to urge focus on ISIL and not fueling rivalries across the country,” a senior U.S. official said, using an acronym for the Islamic State. Local factions are being asked to do the same, and “as the ISIL threat becomes clearer and clearer, it becomes easier to find Libyans who are prepared to do that.”

The French Embassy in Washington declined to comment on French military activity in Libya. “Our priority in Libya is full support to the government and not support to a particular force,” a French diplomatic official said.

A spokeswoman for the Egyptian Embassy in Washington did not immediately respond to a request for comment.

[Five years after revolution, Western nations prepare to renew military operations in Libya ]

Military officials have sought to keep the ongoing presence of U.S. personnel quiet, in part because of Libyans’ sensitivities about foreign troops and also because of the vulnerability of small teams operating in a country gripped by lawlessness. Benghazi was the site of the 2012 attacks that killed four Americans, including the U.S. ambassador.

Last December, a visit by one team of special operators to far western Libya was made public when local militia forces took photos of the Americans with their assault rifles, grenade launchers and GPS devices. The U.S. personnel promptly departed.

The Pentagon is seeking to enhance protection of its advance force from the sky. This year, Italy granted the United States permission to use Italian airfields to launch armed drone flights over Libya for defensive purposes.

Wechsler said the Pentagon had been willing to accept the dangers faced by such teams because of the value they provided to subsequent military operations.

“When the military is dropping Hellfires from a drone, there is by design a zero percent chance of an American getting killed,” Wechlser said. “But when you’re trying to do the important work to understand the human terrain and build up surrogates, the risk . . . can never be mitigated down to zero.”

Thomas Gibbons-Neff contributed to this report.

Read more: