Two Taliban militants hiding handguns in their shoes infiltrated a government compound in southern Afghanistan on Saturday in an attempt to assassinate a provincial governor, setting off a fierce gunbattle that left two security guards and both attackers dead.

The assailants passed through a pair of security checks without their weapons being detected before a guard at the last check _ in the reception room for the governor's office _ noticed something suspicious and stopped them, said Gov. Tooryalai Wesa, the apparent target of the attack. The militants then pulled the guns out of their shoes, shot the guards and took their weapons, he said.

That sparked a shoot-out with security forces that lasted about 30 minutes and left both attackers dead, said Parwiz Najib, a spokesman for the governor. One guard was wounded in the fighting.

Taliban spokesman Qari Yousef Ahmadi claimed responsibility for the attack.

The Taliban routinely target Afghan officials in an attempt to weaken the resolve of a government they say is collaborating with foreign occupiers. Wesa's office said in a statement that Saturday's attack was the ninth to target the governor in the past three years.

Wesa said he was in his office meeting with constituents when he heard shooting out in the reception room.

"There was an explosion," Wesa said, but he did not know whether the blast was caused by grenades or something else.

He and his guests escaped out a back door to the press office, where they waited for the fighting to stop.

Wesa said the assailants came under the pretext of asking for him to intercede on behalf of relatives that had been detained _ a common request.

"The insurgents are not stupid. They had hidden very small guns in their shoes and at two checkpoints they didn't catch them," Wesa said.

Police also discovered two cars parked outside the compound that had been rigged with explosives, apparently ready to be set off if there was a surge of people out into the street, Wesa said. The police defused those bombs, he said.

The assault serves as a reminder of the insurgents' ability to strike in even some of the most secure areas of the country. Earlier this month, militants launched a large-scale coordinated attack on the diplomatic center of the capital, Kabul, and three other cities in which 36 insurgents and 11 others were killed.

Such attacks have raised doubts about the readiness of the Afghan government to take control of security as international forces draw down over the next two years. Afghanistan's international allies have stressed that they do not plan to abandon the country in 2014 and will provide the support needed to help Afghanistan protect its people. Most recently, the U.S. and Afghan governments agreed on a deal earlier this week for a U.S. presence in the country through 2024.

U.S. Sen. John Kerry discussed the long-term pact with President Hamid Karzai on Saturday during an unannounced visit to Kabul. Kerry, the chairman of the Senate Foreign Relations Committee, has repeatedly served as a White House emissary to Afghanistan and Pakistan.

Kerry and Karzai also discussed relations with Pakistan, the president's office said in a statement.

Washington's troubled ties with Pakistan are seen as key to negotiating an end to the Afghan war, but months of efforts aimed at trying to repair the relationship appear to be deadlocked. Pakistani border crossings have been closed to U.S. convoys since November when U.S. forces killed 24 Pakistani troops on the Afghan border. The Pakistani government has demanded a formal apology. The United States has expressed regret, but has declined to go further.

Also Saturday, a roadside bomb in Wardak province's Chak district killed 10 members of the Afghan security forces, officials said, speaking on condition of anonymity because they were not authorized to release the information.

The dead were members of the Afghan Local Police, a government-sponsored militia that works alongside the Afghan army and the national police.

___

Associated Press writers Rahim Faiez and Chris Blake contributed to this report from Kabul.