If Afghanistan had a tourist industry, the postcard-pretty Korengal Valley would be a star attraction. Majestic mountains soar to the heavens. Sunlight spills over terraced fields. Gleaming snow dusts the jagged peaks.

But for the American soldiers stationed there, Korengal is IED Valley, a perilous, exhausting battlefield and the heart of the US war against al-Qaida in Afghanistan.

The sole route into the valley is a roller-coaster mud track that dips and curves through a high-walled canyon lined with hostile villagers and battle-hungry insurgents. Ambushes are frequent but the soldiers' greatest terror is the improvised explosive device (IED) - a hidden roadside bomb that can rip through a Humvee or tip it over a cliff. Last October Lieutenant Richard Baranski narrowly survived a bombing that seriously wounded three others. It was the fifth time Americans had been hit at exactly the same place, he said.

"We've shot missiles into their houses. We've fired mark-19 [grenades] into their houses. And still they are there," he said, pulling on his seatbelt at the start of another journey up the valley. "God, I hate this road."

Soldiers at the American base, informally known as the Kop, feel only slightly more secure. Twelve Afghan labourers who work in the hilltop camp have been abducted and killed this year, some just metres from the main gate. Inside the wire, troops wear their body armour, even to the toilet, out of fear of a sniper who roams the surrounding slopes. Soldiers believe the gunman comes from Chechnya - partly thanks to intercepted radio message and partly because he can shoot straight.

"Most Afghans just spray and pray," said Specialist Brad Hudgens, 23, a sentry at the main observation post above the camp. "This guy is different."

Just moments later his point was dramatically proved. As Specialist Hudgens sat chatting outside his bunker on a rocky mountaintop, a loud crack rang out. A bullet grazed a rock four feet away from him. "Oh shit," said the shaven-headed 26-year-old from South Carolina, reaching for his helmet and scrambling to the roof.

Scanning a distant ridgeline through his sniper gun's sight, Specialist Hudgens frantically searched for traces of the enemy gunman. Spotting a metallic glint among a line of trees, he opened fire. The machine gunner beside him, Private Donovan Maydole, 20, also unleashed a stream of bullets, triggering a rattle of violent echoes across the valley. "I've been waiting a long time to get this motherfucker," growled Specialist Hudgens, searching for a second shot.

Behind them the post commander squinted through binoculars and called coordinates into a radio. Moments later a sharp whistle signalled the arrival of six Howitzer shells from Camp Blessing, six miles away. A cloud of smoke drifted from the ridgeline. Specialist Hudgens rose from behind the sandbags. "If he ain't dead he won't be back for a while," he said triumphantly, carrying his rifle back into the bunker. "Another day at the office." Senior officers later said that they did not think the attacker was the Chechen.

America's war in Korengal is both global and local. Their main interest is the area's rich association with al-Qaida and international terrorism. The valley is home to Abu Ikhlass, an Egyptian jihadi who arrived in Afghanistan in the late 1980s and has never left.

An intelligence officer described him as a "big fish" in the al-Qaida network. Several junior soldiers said they had been told the 9/11 attacks were planned in Korengal. "Are foreigners here? Yes, that's why the American forces are here. This is part of the global war on terrorism," said Captain Jim McKnight, the US base commander.

The immediate and tangible fight is against al-Qaida's local agents. One is the fugitive warlord Gulbuddin Hekmatyar, who sends recruits and military supplies by donkey train from neighbouring Pakistan. "There's one mosque just for Korengal in Peshawar. That's where they take their wounded and resupply," said Captain Joel Hansen at Camp Blessing. But the Americans' more pressing job is to break the link between al-Qaida and stubborn local fighters.

"I could kill the enemy until I am blue in the face. But until the population turns against the insurgency, we're not going anywhere," said Capt McKnight. "That's where we messed up in Vietnam and that's where the British messed up in the American revolution. You have to separate the people from the enemy."

That task may be as steep as the valley walls. Even among fellow Kunaris, the Korengalis are considered a people apart. The men sport dyed red beards, speak a Pashto dialect known only to themselves and are doggedly resistant to outside interference. Many are wealthy lumber merchants through a system of local taxation. During the 10-year Soviet occupation, the Red Army attacked Korengal once but never managed to conquer it. Relations with the US military are no better.

Capt McKnight said some members of the local shura, or council of elders, actively supported the militants by providing fighters or shelter. "They're just a bunch of jerks who are bucking hard against their government," he said. The hostility is reciprocated. Last week Capt McKnight met with the shura to repeat his requests for help. Their main suggestion, however, was that the 28-year-old captain pack his bags.

"The solution is for the Americans to leave. Since they arrived, everything has become so much worse," said Haji Zalwar Khan, 60, clutching a carved stick. His community had no truck with the insurgency, he insisted. "We hear them firing but we have no idea where they are staying," he said, pointing to the mountain peaks. "We can do nothing about it."

The youthful district governor, Muhammad Rehman, is also trying to turn the Korengalis from their al-Qaida godfathers through unorthodox and controversial tactics. In September he banned supplies of flour, cooking oil, Pepsi and other foods from reaching the valley. The Korengalis broke the blockade by mustering donkey trains from other areas. Next Mr Rehman stopped issuing national identity cards to valley residents. Then two weeks ago, after four workers at the American camp were kidnapped, he threatened to raise a tribal fighting force, known as a lashkar, to invade and teach them a lesson.

On Saturday morning the apparent response came. The bodies of three of the four abductees were found dumped on a remote mountainside. They had been shot in the head.

Money and hamfisted governance can be as influential as ideology. Young unemployed farmers are paid up to £2,600 for every IED attack on American soldiers, the governor said. And local leaders are angered at attempts by the Karzai government to regulate the lucrative timber trade. "Lumber is the only business we have. And now they want to take that away," said Haji Zalwar Khan.

As dusk fell one evening last week, Sergeant Jose Urrutia led his platoon to a deserted house on the side of the road where they would spend the night. Strangely, the nearest village was named Taliban. As he rolled out his sleeping bag, the Mexican-born sergeant spoke of the toll the mission had taken.

The soldiers were nearly spent, mentally and physically, he said. His platoon had lost 10 of its 28 men since March, including two dead - one blown out of a truck by an IED, the other shot in the head. They knew their mission was to hunt "bad guys" and help the Afghan government. But for most, avenging 9/11 was no longer a big motivating factor.

"It's been pretty tough," he said. "By now we just want to do our job and get home in one piece. That's it."