Julia Gichuki was fast asleep when she heard the staccato sound of gunfire drawing ever closer to the women’s hostel at her university in the town of Garissa, about 90 miles from the Kenyan border with Somalia.

“I just sprang out of bed and started running,” she told the Guardian. “We didn’t know in which direction to go because bullets were flying everywhere. But we were lucky that the attackers seemed to be targeting the men’s hostel and we managed to flee.”

Julia was one of the lucky ones. By the time militants from the Islamist al-Shabaab group had concluded their deadly rampage, 147 people had been killed and scores were injured, several critically. The gunmen allowed Muslim students to leave the hostel before holding dozens of Christians hostage for more than 12 hours.

Al-Shabaab: from al-Qaida rejects to a fighting force of thousands Read more

The attack – and especially the targeting of young students – has stunned Kenya. It was the worst atrocity in the region since the bombing of the US embassy in Nairobi in 1998, which killed 213 and wounded thousands.

Facebook Twitter Pinterest A Kenyan soldier escorts a woman out of the building after she was rescued. Photograph: Dai Kurokawa/EPA

A visibly shaken President Uhuru Kenyatta addressed the nation on Thursday afternoon and promised to bring the killers to book. “This is a moment for everyone throughout the country to be vigilant as we continue to defeat and confront our enemies,” he said.

The interior minister, Joseph Nkaisserry, appointed to the post recently after his ineffective predecessor was fired following a spate of attacks, said four of the assailants in Garissa had been killed. Five hundred students had been rescued, he said.

A dawn-to-dusk curfew was declared in much of Kenya’s restive north, which borders Somalia and which has been the scene of numerous attacks by al-Shabaab.

Kenyan police offered a $220,000 (£150,000) bounty for Mohammed Mohamud, who they said was the mastermind of the attack.

Arnolda Shiundu, of the Red Cross, said the attack began at 5.30am when several of the militants shot their way through the university gate and began firing randomly.

Facebook Twitter Pinterest Military secure the area outside Garissa University College. Photograph: Nation Media/Barcroft Media

John Ongamo, who is training to be a teacher, described scenes of carnage as the militants killed anyone they identified as a Christian on the spot. “When I heard the gunfire, I slipped out of bed and hid in the wardrobe. The attackers stormed into the hostel and said they wanted to know where the kafirs [unbelievers] were,” he said.

“The girls in the neighbouring hostel started screaming and running and in the confusion I managed to flee. It was terrible. I have never been that scared in my life. They were just spraying bullets around.”

Julia Gichuki was one of about 65 students who scaled a fence and fled to a neighbour’s house. “It was just terrible,” she said. “Some girls were running without any clothes on. There were screams and nobody knew if we would survive. We were so relieved when we managed to scale the fence and a neighbour took us in.”

The biology and chemistry student said she caught a fleeting glimpse of one of the attackers, whom she described as a slight man whose face was covered in a black-and-white keffiyeh and who she said was carrying a “very huge machine gun”.

Kenya, long seen as an island of peace in a turbulent region, has been rocked by a number of attacks by al-Shabaab since 2011 when its troops joined a UN-backed security force that is seeking to tackle the al-Qaida affiliate in Somalia.

Facebook Twitter Pinterest Residents watch at a distance from the university as survivors are led out of the building. Photograph: Stephen Ingati/Xinhua Press/Corbis

African Union troops have pushed al-Shabaab from virtually all major populated centres in the country, but the rebels have hit back with a series of terror attacks in Somalia, Kenya and Uganda, another country contributing troops.

The four-day siege of the Westgate mall in Nairobi in September 2013 that left 67 dead was the highest-profile al-Shabaab atrocity so far, and the north of Kenya, which is primarily settled by Kenyan Somalis, has been the scene of a string of attacks including the massacre of dozens of bus passengers in November.

Britain and Australia issued travel advisory notices last week warning against all travel to the north of Kenya and to Coast province. The tourism industry, the biggest source of employment at the coast, has been seriously affected by the attacks.

Facebook Twitter Pinterest Kenyan president Uhuru Kenyatta addresses the nation after the terrorist attack. Link to video.

In Garissa, crowds of anxious parents and other relatives gathered at the university seeking information on students, but there security forces were unable to say how soon they might attempt to end the hostage drama.

Kenyan troops were patrolling the streets in large numbers and most residents stayed indoors.