MAZAR-I-SHARIF, Afghanistan — Taliban insurgents overran an Afghan Army base and a police checkpoint in northern Afghanistan on Wednesday, killing at least 39 soldiers and police officers, officials said, and a suicide bomber in the capital killed at least 48 people in a classroom.

Hundreds of Taliban fighters carried out the predawn attacks on two units of Afghan forces in the Baghlan-e-Markazi District of Baghlan Province, according to a police official who was at the scene and who spoke on the condition of anonymity because he was not authorized to release the information.

The official said the fighting lasted five hours, and resulted in the deaths of 30 soldiers and nine local police officers. Two other soldiers were also wounded in the battle, he said.

It was the second major attack on an army base in northern Afghanistan in recent days; on Monday, the Taliban killed or captured an entire company of 106 soldiers in the Ghormach District of Faryab Province in the north of the country.