At least 1,000 protesters have staged a demonstration outside the main US base of Bagram in Afghanistan.
Demonstrators vent their anger at the Bagram military base
The demonstrators, chanting "Die America", were angry at the arrest of a number of villagers on Monday night. Some threw stones at military vehicles.
Piles of tyres were burned on the main road near the base, sending clouds of black smoke billowing over the area.
Eyewitness say US troops fired warning shots at the demonstrators. The US military are denying this.
Crowds dispersed after being told the Americans would hand the detainees to Afghan authorities.
The BBC's Andrew North in Kabul says it is thought to be the first major protest by people living near Bagram since the US took over the airfield in 2001.
Some analysts see the demonstration as a further sign of a hardening in the mood among Afghans - who have generally welcomed the foreign military presence in their country over the past few years.
Eight people planning to attack US and Afghan forces had been arrested in an operation close to Bagram on Monday, the US military said.
"Afghan and US forces attempted to contact local leaders to involve them in the operation but were unable to do so," a statement said.
Afghan troops used batons to beat back the protesters as they tried to push down the base's outer gate.
It was not immediately clear if there were any casualties. The protesters said that the Americans should have consulted local authorities first before arresting the villagers.
"We have supported the Americans for years. We should be treated with dignity," local resident Shah Aghar told the Associated Press news agency.
"They are arresting our people without the permission of the government. They are breaking into our houses and offending the people. We are very angry," he said.
Later on Tuesday the US military said the men would be handed over to the Afghan authorities.
"We met with local leaders and we agreed to release the individuals we detained last night into the custody of the local governor," US military spokesman Lt Col Jerry O' Hara told the AFP news agency.
Correspondents say it was the biggest protest in the country since 16 people were killed and scores injured in anti-US demonstrations in May.
The protests were among the largest in Afghanistan this year
Those protests were triggered by an article in the American magazine, Newsweek, which said that prison guards at Guantanamo Bay in Cuba desecrated the Koran, the Islamic holy book.
Newsweek later retracted the article.
Earlier this month, four "dangerous enemy combatants" escaped from Bagram, triggering a huge manhunt.
The US says the four were the first to escape from Bagram.
US soldiers set up checkpoints around the base after they broke out, but so far there has been no sighting of them.
Hundreds of detainees, including Afghan nationals and foreign al-Qaeda suspects, are held at the air base.