Mr. Putin cemented his popularity after assuming power in 2000 by ending a protracted war in Chechnya. Mr. Kadyrov, while often accused of human rights violations, pushed militants out of Chechnya itself into neighboring republics, where the number of attacks rose. Chechnya has remained relatively calm.

The attack on Thursday and the brewing economic crisis in Russia raised simultaneous questions about the signature achievements of Mr. Putin’s presidency: ending the Chechen war and obtaining new prosperity for many Russians.

Most of the violence in the Caucasus goes unnoticed because it takes place outside major urban centers. But Caucasian Knot, an authoritative website that tracks events in the region, said that 290 people had been killed and 144 wounded in fighting in the Caucasus this year through the end of November.

The attack Thursday was the third major assault this year, the website said, following a suicide bombing in Grozny on Oct. 5 that killed five people and the destruction of a government armored personnel carrier by a land mine in April, in which four soldiers were killed and seven wounded.

On Thursday, militants traveling in three cars infiltrated Grozny around 1 a.m., killing three traffic police officers at a checkpoint and then occupying the 10-story House of Publishing at the center of the city, according to a statement by Russia’s National Antiterrorism Committee. Six of the gunmen were killed by security officers inside the building, which was gutted by fire that spread to a nearby market, it said.

The rest of the attackers were found near the House of Publishing in School No. 20, where fighting continued later on Thursday, the statement said. Neither teachers nor students were at the school when it was seized, according to Russian news reports.