The masked attackers 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.
The men took dozens of hostages in a dormitory for several hours as they battled troops and police before the operation was ended after about 13 hours, witnesses said.
Al Shabaab spokesman Ali Mohamud Rage said fighters from the Somalia-based extremist group were responsible for the bloodshed. 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.
Who are Al Shabaab?
Most of the 147 dead were students, but the two security guards, one policeman and one soldier also were killed in the attack, said interior minister Joseph Nkaissery.
At least 79 people were wounded at the school 145 kilometers (90 miles) from the Somali border, Nkaissery said. A dusk-to-dawn curfew was ordered in Garissa and three nearby counties. One suspected extremist was arrested as he tried to flee, Nkaissery told a news conference in Nairobi.
Police identified a possible mastermind of the attack as Mohammed Mohamud, who is alleged to lead Al Shabaab's cross-border raids into Kenya, and they posted a $220,000 bounty for him. Also known by the names Dulyadin and Gamadhere, he was a teacher at an Islamic religious school, or madrassa, and claimed responsibility for a bus attack in Makka, Kenya, in November that killed 28 people.
One of the survivors of Thursday's attack, Collins Wetangula, said he was preparing to take a shower when he heard gunshots coming from Tana dorm, which hosts both men and women, 150 meters (yards) away. The campus has six dorms and at least 887 students, he said.
When he heard the gunshots, he locked himself and three roommates in their room, said Wetangula, who is vice chairman of the university's student union.
"All I could hear were footsteps and gunshots. Nobody was screaming because they thought this would lead the gunmen to know where they are," he said.
He added: "The gunmen were saying, `Sisi ni Al Shabaab,"' — Swahili for "We are Al Shabaab."
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."
The gunmen then started shooting rapidly, as if exchanging fire, Wetangula said.
"The next thing, we saw people in military uniform through the window of the back of our rooms who identified themselves as the Kenyan military," he said. The soldiers took him and around 20 others to safety.
The attack began about 5:30 a.m., as morning prayers were underway at the university mosque, where worshippers were not attacked, said Augustine Alanga, a 21-year-old student.
At least five heavily armed, masked gunmen opened fire outside his dormitory, turning intense almost immediately and setting off panic, he told the AP by telephone.
The shooting kept some students indoors but scores of others fled through barbed-wire fencing around the campus, with the gunmen firing at them, he said.
"I am just now recovering from the pain as I injured myself while trying to escape, Alanga said. I was running barefoot," Alanga said.
As terrified students streamed out of buildings, arriving police officers took cover. Kenya's National Police Service said a "fierce shootout" ensued as police guarded the dorms.
Three of the dorms were evacuated, with the gunmen holed up in a fourth, the National Disaster Operations Center said, and Kenya Defense Forces surrounded the campus.
"I am saddened to inform the nation that early today, terrorists attacked Garissa University College, killed and wounded several people, and have taken others hostage," President Uhuru Kenyatta said in a speech to the nation while the siege was still going on.
Michael Bwana, a 20-year-old student, said he and other survivors tried to call their friends trapped in a dormitory, but their phones were switched off — either by their owners to keep them from ringing or by the gunmen who have seized them.
"Most of the people still inside there are girls," Bwana said, referring to the dorm where gunmen are believed to be holding an unknown number of captives.
Wetangula, who was rescued by troops, said one soldier instructed a group of students to run and to dive for cover at their command as they ran to safety.
"We started running and bullets were whizzing past our heads, and the soldiers told us to dive," Wetangula said. The soldier told students later that Al Shabaab snipers were perched on a three-story dormitory called the Elgon, he said.
Some of the more seriously wounded were flown to Nairobi for treatment, authorities said.
Kenyatta has been under pressure to deal with insecurity caused by a string of attacks by Al Shabaab.
In his speech to the country, he said he had directed the police chief to fast-track the training of 10,000 police recruits because Kenya has "suffered unnecessarily due to shortage of security personnel."
Kenya's northern and eastern regions near the Somali border have seen many attacks blamed on Al Shabaab. The group has vowed to retaliate against Kenya for dispatching troops to Somalia in 2011 to fight the militants following cross-border attacks.
Last month, Al Shabaab claimed responsibility for attacks in Mandera county on the Somali border in which 12 people died. Four of them died in an attack on the convoy of the county's governor.
Police said 312 people have been killed in Al Shabaab attacks in Kenya from 2012 to 2014.
Last week, Al Shabaab claimed responsibility for a siege at a Mogadishu hotel that left 24 people dead, including six attackers.