Hundreds of girls who were abducted last week from their boarding school in Nigeria by a group of armed men have been released.

This is the second time in less than a week that gunmen have returned kidnapped schoolchildren in the country.

The girls were taken on Friday from Government Girls Secondary School in the northern state of Zamfara. Nigerian officials said that the government had been negotiating for their release.

“It gladdens my heart to announce the release of the abducted students of GGSS Jangebe from captivity,” the governor of Zamfara State, Bello Matawalle, wrote on Twitter early Tuesday, referring to their school’s name. Mr. Matawalle did not provide details about how or when they were freed. Officials initially said that 317 girls had been in the group, but later told journalists that the correct number was 279.

The week before the girls were kidnapped, more than 40 children and adults were abducted from a boarding school in Niger state, becoming the latest victims of the West African country’s slide into insecurity. They were freed on Saturday.

The frequency of mass kidnappings of girls and boys at boarding schools in Northwest Nigeria is rising in part because abduction has become a growth industry amid the country’s economic crisis. The victims are increasingly schoolchildren — not just the rich, powerful or famous.

The banditry, one of Nigeria’s many complex conflicts, has even taken place in President Muhammadu Buhari’s home state, Katsina, where more than 300 boys were abducted by armed men in December. They, too, were later released.

The Katsina episode was reminiscent of the country’s most notorious kidnapping, the 2014 abduction of 276 schoolgirls by the Islamist extremist group Boko Haram in the north-eastern state of Borno.

Last week, Mr. Buhari blamed state and local governments for the recent uptick in kidnappings and urged them to improve security around schools.

The girls who were freed this week had been kidnapped from a school in Jangebe town. Mr. Matawalle referred to them on Twitter as the #JangebeGirls.

“I enjoin all well-meaning Nigerians to rejoice with us as our daughters are now safe,” he wrote.