The country’s president said the kidnappers had been found in a forest, in northwest Katsina state, where a secondary school was attacked Friday, and which has been plagued by violence from outlaw gangs.

The Nigerian military engaged in a firefight Saturday with gunmen who had kidnapped scores of secondary school students in northwestern Katsina state the night before, the country’s president said.

President Muhammadu Buhari said in a statement on Saturday that the military had located the kidnappers in a forest and, helped by air support, was exchanging fire with them. One officer was shot and wounded in the fighting with the gang.

In the statement, Mr. Buhari condemned the attack in his home state, and the police said they would deploy additional forces to support the search and rescue.

The gang, armed with AK-47s, stormed the Government Science secondary school in Kankara district about 9:40 p.m. on Friday, the police and residents said. A parent and school employee told newsalertafrica that roughly half the school’s 800 students were missing, but the police and the military were still trying to determine how many had actually been kidnapped.

Police officers at the scene on Friday exchanged fire with the attackers, allowing some students to run for safety, a police spokesman, Gambo Isah, said in a statement.

Katsina is plagued by violence that the government attributes to bandits — a loose term for gangs of outlaws who attack locals and kidnap for ransom. Attacks by Islamic militants are common in northeastern parts of the country.