KABUL—Militants attacked a U.S. Special Operations forces base on Friday night, hours after deadly explosions targeted a Kabul police academy and an Afghan army compound, Afghan and foreign officials said.

An explosion took place outside the headquarters of the U.S. military’s elite special forces in the Afghan capital, triggering a firefight that continued for hours. The base, known as Camp Integrity, is a fortified compound close to Kabul’s airport.

“There was an attack on Camp Integrity at approximately 10:15 p.m. local time,” said U.S. Army Col. Brian Tribus, a spokesman for U.S. and coalition forces in Afghanistan. In a statement Saturday, the coalition said that one of its service members and two insurgents were killed in the attack on the camp. A foreign official said several Americans were injured.

The attack took place hours after a suicide bomber blew himself up among students at an Afghan police academy in Kabul, a senior Afghan security official said. Besides at least 20 fatalities, at least 20 people were wounded.

The Taliban, who are waging an insurgency against the Afghan government and its foreign allies, said they were behind the attacks on the police academy and on the U.S. base.