Gunmen from the Islamist militant group al-Shabaab have killed at least 147 people after storming a university in Kenya.
It is the worst attack on Kenyan soil since the US embassy was bombed in 1998.
The siege ended nearly 15 hours after the Somali group's gunmen shot their way into the Garissa University College campus in a pre-dawn attack, sparing Muslim students and taking many Christians hostage.
Interior Minister Joseph Nkaissery said four gunmen strapped with explosives were behind the attack, the same number that killed 67 people during the 2013 bloodbath at a shopping mall in Nairobi.
"The operation has ended successfully. Four terrorists have been killed," Mr Nkaissery told Kenyan media.
Kenyan police chief Joseph Boinet said the attackers had "shot indiscriminately" when they entered the university compound.
Police and soldiers surrounded the campus and exchanged gunfire with the attackers throughout the day but were repeatedly repelled.
At least 79 people were injured and many were airlifted to Nairobi, Kenya's national disaster body said.
Al-Shabaab, who carried out the deadly attack on the Westgate shopping mall in Nairobi in 2013, claimed responsibility for the raid on the campus in Garissa, a town 200km from the Somali border.
The group has links to al-Qaeda and a record of raids on Kenyan soil in retaliation for Nthe Kenyan government sending troops to fight it in its home nation of Somalia.
Al-Qaeda bombed the United States embassies in Kenya and Tanzania on the same day in 1998, killing 224 people and wounding thousands of people.
The United States condemned the latest attack and offered Kenya help in fighting al-Shabaab.
Images showed dozens of blood-soaked bodies strewn across classrooms, but some students managed to escape unaided.
"We heard some gunshots and we were sleeping so it was around five and guys started jumping up and down running for their lives," an unnamed student told Reuters TV.
Authorities offered a 20 million shilling (€198,000) reward for information leading to the arrest of a man called Mohamed Mohamud, described as "most wanted" and linked to the attack.
Police chief Boinet said Kenya had imposed a dusk-to-dawn curfew on four regions near the Somalia border.
Al-Shabaab, which seeks to impose its own harsh version of sharia law, has separated Muslims from Christians in some of its previous raids in Kenya, notably late last year in attacks on a bus and at a quarry.
Its repeated raids, together with attacks on churches by home-grown Islamist groups, have strained the cordial relations between Kenya's Muslim and Christian communities.
Thursday's attack undermined a renewed drive by President Uhuru Kenyatta to persuade foreigners the country is now safe to visit.
Grace Kai, a student at the Garissa Teachers Training College near the university, said there had been warnings that an attack in the town could be imminent.
"Some strangers had been spotted in Garissa town and were suspected to be terrorists," she told Reuters.
"Then on Monday our college principal told us ... that strangers had been spotted in our college... On Tuesday we were released to go home, and our college closed, but the campus remained in session, and now they have been attacked."
Many Kenyans living in the crime-ridden frontier regions blame the government for not doing enough to protect its citizens from the militants.