GARISSA, Kenya (AP) — Al-Shabab gunmen rampaged through a university in northeastern Kenya at dawn Thursday, killing 147 people in the group's deadliest attack in the East African country. Four militants were slain by security forces to end the siege just after dusk.

The masked attackers — strapped with explosives and armed with AK-47s — singled out non-Muslim students at Garissa University College and then gunned them down without mercy, survivors said. Others ran for their lives with bullets whistling through the air.

Amid the massacre, the men took dozens of hostages in a dormitory as they battled troops and police before the operation ended after about 13 hours, witnesses said.

Al-Shabab spokesman Ali Mohamud Rage said fighters from the Somalia-based extremist group were responsible. The al-Qaida-linked group has been blamed for a series of attacks in Kenya, including the siege at the Westgate Mall in Nairobi in 2013 that killed 67 people, as well as other violence in the north. The group has vowed to retaliate against Kenya for sending troops to Somalia in 2011 to fight the militants staging cross-border attacks.

Most of the 147 dead were students, but two security guards, one policeman and one soldier also were killed in the attack, Nkaissery said.

At least 79 people were wounded at the campus 145 kilometers (90 miles) from the Somali border, he said. Some of the more seriously wounded were flown to Nairobi for treatment.

One of the survivors of Thursday's attack, Collins Wetangula, told The Associated Press he was preparing to take a shower when he heard gunshots.  He heard the attackers arrive at his dormitory, open the doors and ask if the people who had hidden inside were Muslims or Christians.

"If you were a Christian, you were shot on the spot," he said. "With each blast of the gun, I thought I was going to die."

Kenya's northern and eastern regions near the Somali border have seen many attacks blamed on al-Shabab.

Last month, al-Shabab claimed responsibility for attacks in Mandera county on the Somali border in which 12 people died.

Police said 312 people have been killed in al-Shabab attacks in Kenya from 2012 to 2014.

Last week, al-Shabab claimed responsibility for a siege at a Mogadishu hotel that left 24 people dead, including six attackers.