The American ambassador to Tunisia, Donald Blome, offered his condolences to the family and colleagues of the police officer who was killed, identified by Tunisian officials as Lt. Taoufik Missaoui.

“I would like to thank the Tunisian authorities for their immediate protection of the U.S. Embassy today,” Mr. Blome wrote in a message posted on the embassy’s Facebook account, “as well as their rapid response in investigating the situation.”

The attackers on Friday drove a motorcycle toward a police truck, which was parked near the embassy and was damaged in the explosion. Security forces cordoned off the area, which was strewn with debris and body parts.

In recent years, Tunisia has struggled to control a threat from Al Qaeda and other Islamist groups. It remains under a state of emergency, and its porous borders with Algeria and Libya have allowed militants to leave and return.

Tunisians have contributed heavily to the ranks of Al Qaeda and the Islamic State, with at least 5,500 going to Syria and Iraq to fight. As many as 1,500 flowed to neighboring Libya.