The Taliban claimed responsibility for the attack in the Parwan provincial capital of Charikar, some 30 miles (50 kilometers) north of Kabul. The province is home to Bagram Air Field, a sprawling base for U.S. and NATO troops.
The coordinated assault is the most recent in a string of spectacular Taliban attacks within an hour's drive of Kabul — a worrying sign of the insurgency's strength near the heart of the country and its determination to target Afghanistan's nascent leadership.
Early this month, the Taliban shot down a helicopter in a province on the western border of the capital, killing 38 American and Afghan troops. In late June, gunmen killed at least 21 people in an attack on the Inter-Continental hotel in Kabul itself.
The violence is a sign of NATO's broader struggles in the east, where persistent insurgent attacks forced the alliance to pull forces back from outlying patrol bases and outposts. The coalition, which plans to send 10,000 troops home by the end of the year, is considering whether to move forces from Taliban heartlands in the south to reinforce troops fighting insurgents in the east.
Southern provinces like Kandahar and Helmand are the Taliban's traditional stronghold, while the east is a base of operations for many Pakistani based Taliban and international terrorist affiliates like al-Qaida and the Haqqani network.
Afghanistan's eastern border with Pakistan is also a common thoroughfare for insurgents attempting to strike Kabul, although Parwan is considered to be relatively secure.
Sunday's assault began with a car bomb outside the front gate, police said. The blast blew open a hole in the wall, allowing five insurgents wearing suicide vests and carrying automatic weapons and rocket propelled grenades to rush into the compound.
Afghan police said they killed three of the attackers as they approached the governor's house.
The attack took place during a high-level provincial security meeting attended by Parwan Gov. Abdul Basir Salangi, his police chief, intelligence director, a local army commander and at least two NATO advisers.
Salangi told The Associated Press that he and his aides fired from their meeting room with AK-47s. He claimed to have killed at least one of the insurgents himself.
"I had an AK-47. I shot him and from the window of my waiting room," said Salangi, who was formerly the police chief of Kabul and a rebel fighter during the Soviet occupation of Afghanistan in the 1980s. He said it was the second time in the past month he was targeted by an assassination attempt.
Provincial Police Chief Gen. Sher Ahmad Maladani also took part in the gun battle, which he said lasted for approximately one hour.
"The last attacker was killed by police when he was only about 15 meters away from me," said Maladani. The bomber was killed before he could detonate his explosives.
The attack left much of the compound in ruins. Part of the governor's offices were burned. Broken glass and body parts littered the courtyard. Several cars were wrecked by explosions and bullets.
Sixteen of the dead were civilian Afghan government employees and six were policemen, according to the Afghan Interior Ministry.
Meanwhile, the French Defense Ministry said one of its soldiers was killed Sunday by isolated fire during an operation in the northeast province of Kapisa.
The death brings to 382 the number of coalition service members killed in Afghanistan 2011 and 59 in August.
Seventy-four French troops have been killed in Afghanistan since 2001. About 4,000 French troops are taking part in NATO-led operations against the Taliban, and France says 1,000 troops will be brought home next year, with a full withdrawal of combat forces in 2014.