Updated

A security operation is over and 147 people have been killed in an attack Thursday by Al Qaeda-linked terror group Al-Shabaab on a Kenyan college, officials said.

The officials said four attackers were killed during the operation.

The siege on Garissa University also left dozens more injured and hundreds of students unaccounted for.

Hours after the assault began, Kenyan security forces cornered the gunmen in a dormitory at the school, and President Uhuru Kenyatta said in a speech to the nation that the attackers were holding hostages.

"There are many dead bodies of Christians inside the building," Al-Shabaab spokesman Sheikh Abdiasis Abu Musab told Sky News. "We are also holding many Christians alive. Fighting still goes on inside the college."

Collins Wetangula, the vice chairman of the student union, said when the gunmen arrived at his dormitory he could hear them opening doors and asking if the people who had hidden inside whether they 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."

A spokesman for the terror group told the BBC that it attacked the school because “it’s on Muslim land colonized by non-Muslims.” The spokesman also said the gunmen had separated non-Muslims from Muslims and had freed 15 of the latter group.

The interior ministry said around 500 of 815 students have been accounted for, but hundreds remain missing. The students at Garissa are predominantly non-Muslim, a source told Fox News.

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.

The attack occurred at 5:30 a.m. local time (10:30 p.m. Wednesday E.T.) during morning prayers at the university mosque, according to Augustine Algana, a student at the school who survived the attack and spoke to the Associated Press.

Algana said gunfire rang throughout campus while students were still sleeping.

Terrified students sprinted out of buildings as police officers arrived on the scene. The gunmen had opened fire at guards triggering a “fierce shootout” with police guarding student dorms, Kenya’s National Police said in a statement.

Wetangula said he was preparing to take a shower when he heard gunshots coming from Tana dorm, which hosts both men and women, 150 yards away.

He said that when he heard the gunshots he locked himself and three roommates in their room.

"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. "The gunmen were saying sisi ni Al-Shabaab (Swahili for we are al-Shabaab)," 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," Wetangula said. The soldiers took him and around 20 others to safety.

"We started running and bullets were whizzing past our heads and the soldiers told us to dive," Wetangula said. He said the soldier told the students later that Al-Shabaab snipers were perched on a three story dormitory called the Elgon and were trying to shoot them.

The Kenya Red Cross said on Twitter that 65 injured people were taken to a hospital and four of them were in critical condition. Kenya’s National Disaster Operations center said most had gunshot wounds. Authorities said some of the more seriously wounded were being flown to Kenya’s capital, Nairobi.

Kenya's northern and eastern regions, which border Somalia, have been plagued by attacks blamed on Al-Shabaab, an Islamist group from Somalia.

The militant group has vowed retribution on Kenya for sending troops into Somalia to fight the militants. Kenya sent its military there in 2011 to fight al-Shabaab following cross-border attacks.

Last month, Al-Shabaab claimed responsibility for attacks in the county of Mandera on the Somali border in which twelve people died. Four of them died in an attack on the convoy of Mandera County Governor Ali Roba.

Al-Shabaab carried out large-scale attacks in Mandera last year. The militants hijacked a bus and singled out 28 non-Muslims forcing them to lie on the ground before shooting them dead. Ten days later, 36 non-Muslim quarry workers were killed by the extremists.

Police statistics show that 312 people have been killed in Al-Shabaab attacks in Kenya from 2012 to 2014. Thirty-eight people were killed and 149 wounded in Garissa in the same period, according to police statistics.

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."

Fox News' Paul Tilsley and The Associated Press contributed to this report.