GUSAU, NIGERIA -- Hundreds of Nigerian girls abducted last week from a boarding school in the country's northwest have been released, a state governor said Tuesday, as the West African nation faces a spate of school kidnappings.

The girls, ages 10 and up, dressed in light blue hijabs and barefoot, packed into Zamfara state's Government House conference room. They appeared calm, chatting to one another as they sat in long rows while journalists photographed them. They will receive a medical checkup before being returned to their parents.

Zamfara Gov. Bello Matawalle said that 279 girls had been freed after being abducted from the Government Girls Junior Secondary School in Jangebe town on Friday. The government last week said 317 had been kidnapped. It was not clear if the higher number was an error or if some girls were still missing.

"Alhamdulillah! (God be praised!) It gladdens my heart to announce the release of the abducted students," Matawalle said in a post on Twitter early Tuesday. "I enjoin all well-meaning Nigerians to rejoice with us as our daughters are now safe."

Officials said "bandits" were behind the abduction, referring to the groups of armed men who operate in Zamfara state and kidnap for money or to push for the release of their members from jail.

At the time of the attack, one resident told The Associated Press that the gunmen also attacked a nearby military camp and checkpoint, preventing soldiers from responding to the school.

One of the girls recounted the night of their abduction to the AP.

"We were sleeping at night when suddenly we started hearing gunshots. They were shooting endlessly. We got out of our beds and people said we should run, that they are thieves," she said. Officials ended the interview before the girl could give her name.

The attackers eventually found her and some classmates and held guns to their heads, she said.

"I was really afraid of being shot," she said, adding that they asked for directions to the staff quarters and the principal. "We said we don't know who she is."

Nigeria has seen several such attacks and kidnappings in recent years, the most notorious in 2014, when 276 girls were abducted by the jihadist rebels of Boko Haram from the secondary school in Chibok in Borno state. More than 100 of those girls are still missing.

Boko Haram is opposed to western education and its fighters often target schools. But most attacks in the northwest are perpetrated by armed criminal groups with no such ideology.

Police and the military have been trying to rescue the girls from the Zamfara abduction, which caused international outrage. Officials did not say if a ransom had been paid for their release.

"We have been in discussion since Friday with the abductors and reached agreement on Monday," the governor said, adding that he would ensure additional security at all schools in the state.

President Muhammadu Buhari expressed "overwhelming joy" over the release of the girls.

"I join the families and people of Zamfara state in welcoming and celebrating the release of these traumatized female students," he said in a statement. "Being held in captivity is an agonizing experience not only for the victims, but also their families and all of us."

The president called for greater vigilance to prevent bandits from carrying out such attacks -- but warned that paying money for the release of victims would only result in more assaults.

Ernest Ereke, of the University of Abuja, agreed that ransoms are allowing criminal groups to buy more arms and expand their power.

And the Nigerian state increasingly looks too weak to respond, he said.

"It is a lucrative venture in a country where a lot of young people are impoverished, jobless and hungry," he said. "The state, which should confront these criminals, is enabling them by always pandering to their dictates. It should be the other way round, that is, the criminals should be scared of the state, but, in this case, it is the state that is scared of criminals."

"If the state is not able to crush them," he added, "it means something is wrong with the Nigerian state."

On Saturday, 24 students, six staff and eight relatives were released after being abducted on February 17 from the Government Science College Kagara in Niger state. In December, more than 300 schoolboys from a secondary school in Kankara, in northwestern Nigeria, were taken and later released. The government has said no ransom was paid for the students' release.

------

Olukoya reported from Lagos, Nigeria. AP writer Carley Petesch in Dakar, Senegal contributed