WASHINGTON — Four U.S. military personnel assigned to the U.S. Embassy in Tripoli, Libya, were detained Friday and then released after being held for hours by the country’s Interior Ministry, U.S. officials said.

The four were believed to have been reviewing potential evacuation routes for diplomats when they were detained, according to initial information received by officials in Washington, D.C.

The place they were said to be detained is not far from the main road to the Tunisian border from Tripoli, Libya’s capital.

After running into a problem at a checkpoint — many of which are run by local militias — the four were detained and later moved to the Interior Ministry, said administration officials who asked not to be identified.

Save 75% on a Digital Subscription Today

The U.S. State Department confirmed the detention but provided no information on how it had happened.

“We are seeking to further ascertain the facts,” said Jen Psaki, the U.S. State Department spokeswoman.

Photographs of two U.S. passports and embassy-identity cards were later disseminated on Twitter. It was not known if the passports belonged to any of the four military personnel.

The buzzing sound of drones filled Tripoli’s sky for hours as rumors spread through the capital that four Americans were missing. Drones are not usually heard in Tripoli, although the sound is familiar in Benghazi.

The detention appears to have taken place in a town near the historic Roman ruins at Sabratha and about an hour’s drive from Tripoli.

The area is not known for anti-Western extremists or other obvious threats.

In part because it is a tourist area, the district around Sabratha skews relatively liberal and friendly to Westerners.

Since the attack on the U.S. mission in Benghazi that killed Ambassador J. Christopher Stevens on Sept. 11, 2012, employees of the U.S. Embassy have operated with extraordinary caution.

But two years after the toppling of Moammar Gadhafi, security remains tenuous even in and around Tripoli.

Libya’s transitional government has not managed to assemble a credible national army or police force.

Many families or clans around the country keep heavy weapons, as do autonomous local militias formed during and after the Libyan uprising.

Rigorous security rules preclude any movements outside the heavily fortified embassy compound without advance planning and an armed guard.

The compound is locked at night, and no one is permitted to enter or exit.