The United States has captured a key suspect linked to the deadly 2012 attack on an American consulate in Benghazi in a secret raid in Libya over the weekend, US President Barack Obama announced.

"Since the deadly attacks on our facilities in Benghazi, I have made it a priority to find and bring to justice those responsible for the deaths of four brave Americans," Obama said on Tuesday in announcing the capture of Abu Khatallah.

"The fact that (Khatallah) is now in US custody is a testament to the painstaking efforts of our military, law enforcement, and intelligence personnel. Because of their courage and professionalism, this individual will now face the full weight of the American justice system," he said.

The US said that the Libyan government has been informed of the operation, but declined to say whether Libya was notified prior to the capture.

Rear Admiral John Kirby, US defence deparment spokesman, said there were no civilian casualties in the raid, which took place on Sunday, and the suspect was in US custody at a "secure location outside of Libya."

After similar raids, the US has held suspects aboard naval ships before flying them to the US to face legal charges.

Kirby said all US troops and personnel taking part in the operation have "safely departed Libya."

The US State Department identified Khattalah as a senior leader of Ansar al-Sharia, a Libyan armed group it brands a "terrorist" organisation responsible for many attacks and assassinations.

US authorities had filed charges against Khatallah and others over the 2012 Benghazi attacks, which killed four Americans, including the US ambassador to Libya, Christopher Stevens.

The embassy deaths triggered a long-running investigation in the US, with the Republican opposition accusing Obama and then-US Secretary of State Hillary Clinton of mishandling the security of the embassy.

A US Senate report also said that the US military was not positioned to aid the Americans in need, though the head of Africa Command had offered military security teams that Stevens had rejected weeks before the incident.

Al-Qaeda-linked armed groups were later blamed for the strikes, first when armed groups overran the temporary US mission on September 11, 2012, and later that same night, when armed fighters fired mortars at the nearby CIA annex where the Americans had taken shelter.