A bloody day of violence and terror at a Kenyan college finally ended Thursday night with "all four terrorists" and at least 147 other people dead, authorities said.
The shocking rampage at Garissa University College came to a bloody conclusion at 9:30 p.m. local time (2:30 p.m. ET), Kenyan officials said — more than 16 hours after the gunmen stormed the school, targeting Christians and taking hostages.
The al Qaeda-linked extremist group al Shabab claimed responsibility for the siege.
Masked attackers "shot indiscriminately" and "heavy gunfire and explosions" were heard during the standoff, authorities and eyewitnesses said. The country's Ministry of Interior said about 587 people were safely evacuated, while another 79 were injured. All students were accounted for, officials tweeted.
The four attackers had strapped themselves with explosives and blew up "like bombs" when they were shot, Kenyan Cabinet Secretary for Interior Joseph Nkaissery, said.
The massacre is believed to be the deadliest terror attack in Kenya since the 1998 U.S. Embassy bombings in Nairobi, which killed 213 people, according to observers.
What is Al Shabab?April 2, 201501:21
The gunmen were part of an al Shabab intelligence unit based in neighboring Somalia, a U.S. counterterrorism official told NBC News. The force, known as Amniyat, had been planning the attack for "a long time," the official said. Its leader, Mohamed Kuno, has been hunted by Kenyan authorities for years and was described by the U.S. official as a "hard-core" jihadi.
The Ministry of Interior confirmed to NBC News that Kuno was the same man featured in a wanted poster it issued earlier in the day. The poster offered a reward equivalent to around $215,000 for Kuno, although the poster itself referred to him by several other aliases.
Among the 147 killed were the four terrorists, according to the official Twitter account of the Kenyan presidency.
The U.S. offered assistance to the Kenyan government. "The United States condemns in the strongest terms today's terrorist attack against the innocent men and women of Garissa University College in eastern Kenya," White House spokesman Josh Earnest said in a statement.
"The United States stands with the people of Kenya, who will not be intimidated by such cowardly attacks," he said.
Al Shabab, which is based in neighboring Somalia, claimed responsibility for the pre-dawn attack. Sheik Abdiasis Abu Musab, the group's military operations spokesman, said many Christians were being held by the militants. "We sorted people out and released the Muslims," he told Reuters.
A student whose high school is just across the street from Garissa University College told NBC News he was walking to school when he heard gunfire and explosions. The gunfire had been ongoing for more than 12 hours, said the 16-year-old, who is not being named by NBC News.
"You can still hear it now," he said at 6 p.m. local time (11 a.m. ET). "There was a lull but now the shooting has intensified again in the last ten minutes."
Backing up what other eyewitnesses have said, the student told NBC News that his best friend, who is on the basketball team at the university, was allowed to leave by the attackers after proving he was a Muslim by reciting the Shahada.
Police have imposed a 6:30 p.m. to 6:30 a.m. curfew in Garissa and the surrounding counties until April 16, the Kenya National Disaster Operation Centre said.
Collins Wetangula, the vice chairman of the student union, said he was preparing to take a shower when he heard gunshots.
When the gunmen arrived at his dorm 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," Wetangula told The Associated Press. "With each blast of the gun I thought I was going to die."
He added: "We started running and bullets were whizzing past our heads and the soldiers told us to dive."
Eyewitnesses Ran For Their Lives From Kenyan Gun AttackApril 2, 201500:45
Aden Abubakar, 29, who works in construction in Garissa, told NBC News he had just finished praying when he heard gunshots and explosions from the university around 500 yards away. Abubakar said he saw students running from the university compound "helter skelter," some of them naked or partially naked as they had been sleeping when the violence erupted.
Authorities said the attackers were holed-up inside dorms after a lengthy gunbattle with security services. Officials said the town was "locked down."
Local residents donated blood outside Garissa hospital in the shade of a tree.
The Interior Ministry said one "suspected terrorist" had been arrested trying to flee the scene of the siege.
Red Cross Kenya spokeswoman Arnolda Shiundu told NBC News that 50 students had been “safely freed” from the college compound after the attackers struck.
According to Shiundu, the attack began at around 5 a.m. local time (10 p.m. Wednesday ET) with an explosion at the university's gate. The masked gunmen then forced their way into the compound and moved toward accommodations for female students, she added.
In a televised statement, Kenyan President Uhuru Kenyatta admitted that the country had "suffered unnecessarily due to shortage of security personnel." He said he had directed police chiefs to fast-track 10,000 pending officer recruits to report for duty immediately.
Al Shabab has carried out past attacks in Kenya. In 2013, it claimed responsibility for an assault on Nairobi's upscale Westgate Mall that left more than 60 dead.
Robert Godec, the U.S. ambassador to Kenya, condemned what he called a "heinous terrorist attack" by al Shabab.
FROM OCT. 2013: Shocking new video of the Westgate Mall attackOct. 17, 201301:36
Police statistics show that 312 people were killed in al Shabab attacks in Kenya from 2012 to 2014.
In February, al Shabab released a video calling for attacks on shopping malls in the U.S., Canada and the U.K.
Thursday's university attack comes three days after President Barack Obama announced he would visit the East African country in July. It also prompted the State Department to urge U.S. citizens in Kenya to "review their own personal security measures."
Photo Gallery: Al-Shabab Gunmen Storm University in Kenya
NBC News' David Wyllie and Jason Cumming, The Associated Press and Reuters contributed to this report.