Security forces also said they had thwarted three massive militant bombings, underscoring security fears for Sunday's vote.
The violence came a day after the Taliban called for a boycott of the polls. They said they would not attack civilians going to vote, but would target areas where U.S.-led coalition forces were deployed and advised people to avoid such places.
About 100,000 Afghan police and soldiers and 30,000 foreign troops are on alert across the country to safeguard Sunday's polls. In Kabul, road checkpoints have sprung up, with police pulling over vehicles ranging from hay carts to ribbon-decked wedding cars.
In Kandahar, all vehicles were banned from driving inside the city after midday Saturday due to fears the militants will use car bombs.
In an unusually brazen attack on the outskirts of the capital, Kabul, militants ambushed a security patrol, killing a district police chief and two officers, said Interior Ministry spokesman Luftullah Mashal.
"This is the first attack so close to Kabul that we have seen in a long time," he said. "The Taliban and al Qaeda are trying their best to create problems."
Guerrillas also ambushed a police patrol on the main highway linking Kabul with the southern city of Kandahar, triggering a gunbattle that left seven militants dead, said Gulam Rasool, a government chief in Sharisafar district.
An insurgent rocket slammed into a police car, setting it afire, but all the officers inside escaped, he said.
Two Taliban rebels were also killed during fighting in Kandahar province Thursday, according to a Defense Ministry statement. Eight suspected rebels were arrested, it said.
In another attack in Kandahar, rebels used a roadside bomb to attack a police chief as he was driving. It blew up his vehicle, but all inside survived with minor injuries, officials said.
Mashal said the intended targets of the three thwarted bombings weren't immediately clear.
Police in eastern Kunar province detained two Pakistanis, suspected to be Taliban members, armed with 45 pounds of explosives.
Also, soldiers at a checkpoint in central Ghazni province stopped a vehicle with C-4 high explosive hidden under its seats. A second car bomb was found in eastern Paktika province when security forces discovered 660 pounds of explosives in the back of a pickup truck.
Election workers have been putting the final touches on poll preparations, using donkeys, dilapidated trucks and helicopters to haul millions of paper ballots to more than 6,000 polling centers.
Hopes are high the vote will end a quarter-century of violence and sideline the rebels by demonstrating public support for democracy. But the Taliban and other militants showed no signs of letting up in their attacks.
The deputy commander in charge of U.S. military operations in Afghanistan, Brig. Gen. James G. Champion, said he expects the Taliban to continue violent efforts to disrupt the polls but does not believe a large, coordinated attack is coming.
The insurgents have threatened a "spectacular event," said Champion, speaking to Pentagon reporters in Washington.
"We have not seen the ability of the enemy here in Afghanistan to mount coordinated attacks across the country," he said. "They would be looking for that one event to get into an area and cause damage and loss of life ... but I don't see any kind of situation happening like you're seeing in Iraq."
Top Afghan officials say they are confident of successful elections.
"All our police and soldiers are now in place and are ready for anything. I am absolutely sure the elections will proceed very smoothly," Defense Minister Rahim Wardak told The Associated Press. "People are very excited and they want these polls to bring peace and stability."