WASHINGTON — American commandos captured a suspect in the 2012 attacks in Benghazi, Libya, the Trump administration said on Monday, bringing into custody a second man accused in the terrorist attacks that have been used by Republicans as a political spear against the Obama administration.

The man, Mustafa al-Imam, was caught on Sunday in the area of Misurata, Libya, brought aboard a United States warship and will be taken to the United States to face criminal charges, American officials said. Four Americans, including Ambassador J. Christopher Stevens, were killed in the bloody September 2012 assaults at a diplomatic compound and a C.I.A. base a mile away that came under heavy fire. More than a dozen people have been charged, and one is standing trial.

“To the families of these fallen heroes: I want you to know that your loved ones are not forgotten, and they will never be forgotten,” President Trump said in a statement on Monday. “Our memory is deep and our reach is long, and we will not rest in our efforts to find and bring the perpetrators of the heinous attacks in Benghazi to justice.”

The team of commandos — members of the Navy SEAL team 6 and the F.B.I.’s Hostage Rescue Team — surprised Mr. Imam, several officials said. One said Mr. Imam was subdued. Details about the operation were limited, but the officials said that plans to apprehend him had been in the works for months as the American military waited for authorization from the White House.