I Anibal Paz is nearly surrounded. The sergeant and his squad of 15 or so Marines are crouched behind the crumbling mud walls of a small Afghan compound taking fire from three directions. Hiding in the tree line to the south, guerrillas pepper the Marines with automatic weapons fire. From a cornfield to the west come more AK-47 bursts. Most worrisome, though, are the bullets whizzing in from a squat building in a second compound a few hundred yards to the southeast. These are sniper shots from a bolt-action rifle. Unlike the AK barrage, they get closer with every round.

Paz barks at his soldiers to return fire. His urgent, gravelly voice doesn't quite match his boyish face with its smooth, round cheeks, long eyelashes, and tidy black mustache. Paz, the son of a Portuguese Special Forces soldier, was raised in Fall River, Massachusetts, and grew up to be a self-proclaimed "Masshole," true to his Celtics, Patriots, and Red Sox. He did two tours in Iraq and took part in the Marines' biggest battle in a quarter century, 2004's invasion of Fallujah. To his surprise, he's finding Afghanistan even more relentlessly violent than Iraq: His unit, Echo Company, has traded fire with the Taliban three out of every four days it has spent in this small farming community, called Mian Poshteh, roughly 100 miles from the border of Pakistan's Balochistan province.

A bullet whizzes just left of Paz. Then another to the right. He waves over a Marine carrying a backpack-sized radio and grabs the green handset. "We're receiving accurate fire from the compound!" he shouts over the rattle of machine gun bursts.

It was supposed to be a simple mission. Paz and his squad were told to hunker down at this compound — a collection of broken adobe buildings with a dusty, tree-shaded courtyard called Moba Khan — for a day and a half, monitoring the area to see who came and went. A small reconnaissance team had the hard part: ambushing a group of Taliban who, the Marines had learned, would be meeting in the next compound up the road. But the attack didn't go smoothly. There were more militants, and more guns, than anticipated. In the ensuing firefight, two Marines were shot and four more were injured by an improvised explosive. The recon team successfully made it back to the company's nearby headquarters and nobody died, but it was a matter of luck and quarter-inches. Since then, Paz and his squad have been battling the insurgents. Mortars, artillery, and rockets from Cobra helicopters have all failed to stop the Taliban assault.

A pair of F-15 jets circle overhead. Cameras on the bellies of the aircraft capture the standoff: the opposing compounds, the tree line to one side, the fields between. The images are relayed to Echo's headquarters, a burned-out schoolhouse just over half a mile away surrounded by sandbags and mortar tubes. Inside the school, Eric Meador, the company commander, leans over a small table and looks at the footage on a laptop. Meador is on the small side — 5'9", 140 pounds — and is a bit quirky for a Marine officer. A former Mississippi cop from a family of musicians, he has a weakness for chewing tobacco and reality TV — he keeps a picture of Kate Gosselin on one wall of the schoolhouse. But he radiates authority, and in the command post everyone focuses on him. Meador asks air controller Josh Faucett to review the standoff. "This is where the friendlies are," Faucett says, pointing to the screen. "This is where we think the sniper is." It's a building in the northern compound, next to the main east-west road.

The next step seems obvious: Call those F-15s and have them reduce the Taliban's positions to rubble. That's how the Marines took out insurgents in Fallujah in 2004. Hell, it's how they went after the Taliban in August 2008. But it's August 2009, and today Meador is not sure.

A month earlier, just as Meador, Paz, and 4,000 other Marines were getting ready to move into Helmand province, the US military modified its counterinsurgency strategy. Incoming top general Stanley McChrystal issued strict guidelines forbidding air strikes except in the most dire circumstances. The number one priority in Afghanistan, he declared, was to secure the population so normal life could resume. The US needed to rob the militants of popular support, he argued. Dropping bombs only disrupted lives and drove people into the arms of the Taliban. So civilian casualties from air strikes had to stop — immediately.

Captain Eric Meador on a mission in Helmand province.

Photo: Getty Images 2009 Getty Images

The directive has required a radical shift in the approach to Afghanistan. For most of the first eight years of the war, the US and its allies relied heavily on air power to keep militants in check. US aircraft, the generals believed — with their precision bombs, sophisticated targeting, and sheer omnipresence — could minimize the number of troops required to wage the war. The problem is that air strikes — even with maximum precision and care — can alienate the people needed most for a successful counterinsurgency campaign. America's mightiest engineering accomplishments — drones and smart missiles — are actually impediments to the social engineering required in Afghanistan. So with a single stroke, McChrystal took the US's biggest technological advantage off the table. The military would have to make do without one of its most potent weapons.

It hasn't been easy. While accidental civilian deaths dropped by 87 percent in the eight weeks following the order, American fatalities have more than doubled from 2008 levels. And to make the plan work, McChrystal will get 37,000 more US and NATO troops. At the highest levels of the Obama administration, many top officials pushed to remake the Afghanistan campaign in the mold of the Pakistan air war next door: more drone strikes and fewer troops to get caught in the cross-fire. Soldiers can only do so much to rebuild this rugged society from the ground up, they argued. Let the drones take the lead, fighting this conflict from the safety of the skies. But for now, McChrystal's approach has won out. He travels to Capitol Hill in early December to defend his war plan.

While the debate rages in Washington, the Marines on the ground are mostly on their own. Even with Paz's squad being attacked from three sides, a bombing run is not automatic. The Marines not only have to prove that civilians won't be hurt, they also must guarantee that the bombs won't so much as scratch civilian homes.

Back at Echo's schoolhouse headquarters, Faucett stares at an aerial view of Moba Khan on his tablet computer. He sees a problem: The building Paz has identified as the sniper's perch is next to several farmhouses. "Man, the target house is right on the edge of that village," Meador says, rubbing his shaved scalp with the palm of his hand. If he orders a strike that hits a farmer's kid instead of a sniper, the Taliban will have some angry new allies, and the brass will be apoplectic. Meador wants to protect his men. But he also can't be sure who or what a bomb would hit. Meador tells Faucett to wave off the F-15s — and hopes he hasn't made a serious mistake.

II A year ago it would have been easy for Dave "Smoke" Grasso and Sean "Sticky" Flor to come to Paz's rescue. But today the pilots linger on the tarmac of a clandestine air base, hundreds of miles outside Afghanistan, in their tan flight suits and Top Gun shades (Grasso completes the look with his brown hair trimmed into a flattop). Next to them sits their plane, a B-1 bomber, perhaps the most lethal flying machine in the US arsenal. It is capable of delivering up to 48,000 pounds of bombs in a single sortie — enough to obliterate the enemy outpost at Moba Khan, the cornfield, the tree line, and everything else in the vicinity. But this destructive hardware is now largely kept leashed.

Before McChrystal issued the new restrictions on bombing, Grasso and Flor had two main jobs: They would demolish fixed targets — Taliban hideouts identified by aerial or on-the-ground intelligence — or, alternatively, they played "roving linebacker," dashing over to wherever American troops were in trouble and eliminating that trouble. If there was a choice between killing Taliban and saving some locals' homes, the buildings got it. If it was a choice between killing Taliban and saving some locals ... well, let's just say they dropped a lot of bombs. "This guy here," Grasso says, pointing at Flor, "was a bomb-dropping machine." Twice, during a single mission, Flor has dropped all 12 of his 500-pound bombs and all eight of what he calls his 1-ton "crowd-pleasers."

They hit their stride in the summer of 2008, with the air war at its peak. The US unloaded 587,000 pounds of ordnance in June and July of that year — as much as was dropped in all of 2006. Not surprisingly, there were accidents. In July, a bombing in Nangarhar province wiped out 47 civilians on their way to a wedding party, including the bride. In October, a coalition air strike hit an Afghan army checkpoint in Khost province, killing nine soldiers.

This naturally enraged the Afghans. By November, president Hamid Karzai was calling for a radical de-escalation to the air war: "The fight against terrorism cannot be won by bombardment of our villages."

The Americans politely blew off these demands. The US had viewed air power as its most important advantage in this war since 2001, when a fleet of bombers and fighter jets — and minimal US ground forces — helped rout the Taliban. In 2008, with roughly 30,000 troops patrolling a country the size of Texas, the US was still heavily reliant on air strikes. Not only is Afghanistan 50 percent bigger than Iraq (where, it should be noted, the US had five times as many forces), but much of the country's terrain is so rugged that the only way to attack targets is by air. Collateral damage was seen as a necessary evil.

At least, this was the attitude until last May. That's when a B-1 and a pair of F/A-18Fs came to the aid of a group of Marines and Afghan soldiers locked in a shoot-out with militants in Farah province. The Taliban hunkered down in an area teeming with hundreds of civilians. Over the course of the standoff, the B-1 pilots dropped three 1-ton munitions and five 500-pound bombs. The pilots believed they were unloading on buildings that had been emptied of women and children. They were wrong. "It was like Judgment Day," one witness told Human Rights Watch. "Who can bear to see so many killed, from a two-day-old baby to a 70-year-old woman?" Dozens of civilians died. President Obama promised to "make every effort to avoid civilian casualties" in the future. Later that month, he named McChrystal the new commander for the Afghanistan war.

This Air Force operations center now coordinates only three to five aerial assaults a month.

Photo: Courtesy of US Air Forces Central

On July 2 — after two weeks on the job — McChrystal issued his new "tactical directive."

"We must avoid the trap of winning tactical victories — but suffering strategic defeats — by causing civilian casualties," he wrote. This didn't just mean minimizing the number of bystanders killed — it meant not having any. Under McChrystal's rules, units were even supposed to consider retreating from a fight rather than calling in an air strike.

These days, Grasso and Flor spend most of their flying time using souped-up video cameras to monitor action on the ground — without unloading their weapons. Pilots still have vital roles to play — ferrying supplies, surveilling hostile terrain, zooming over convoys in hopes of intimidating potential attackers — but dropping bombs is increasingly not one of them. Grasso says he's on board with the new directive. "Every time I drop a bomb and kill one innocent Afghan, I set the war back — even if I killed 100 Taliban," he says. And maybe, Grasso admits, he was a little overeager to drop bombs last year. "When you've got a truckload of food, everyone looks hungry. So when everything looks suspicious, when you're looking for suspicious stuff, you almost want it to be suspicious."

That's not to say complying is easy. "It's frustrating, sitting up there, knowing guys are on the ground, getting shot at," Grasso says. "You're a roving linebacker. But they keep running the ball out of bounds."

On the tarmac, a maintenance crew loads a rack of 500-pound bombs into his B-1. A public relations officer offers me a white marker, asking if I want to sign one of the munitions. No thanks, I say. Grasso takes the marker. "Bring the hate," he writes.

III With the F-15s gone, Paz and his squad must fend for themselves. Luckily, the Taliban fighters don't press, and after a few hours the shooting peters out. The sun begins to set. Knowing the militants are still out there somewhere, the Marines squat in the compound courtyard, swatting away mosquitoes and eating MREs. Paz and the unit's ranking officer, Patrick Nevins, set up a schedule for the night; the Marines switch off doing two hours of guard duty, then grabbing two hours of sleep.

As day finally breaks, the Marines are running low on food and water, so Nevins plans a resupply mission. He will take most of the squad with him, and Paz will stay with a team of four to defend the compound. It's about 10 in the morning when Nevins and his men file out the back of the compound, alongside an irrigation ditch.

At 10:15 bullets explode from the southern tree line.

Normally, the Taliban fire in quick bursts and then pause before shooting again — a sign of unschooled, undisciplined fighters. This time, it's a sustained stream of fire. And as soon as it ends, another barrage starts from the cornfields. This is a coordinated attack, orchestrated by someone well versed in infantry warfare. And judging by the number of guns firing, that pro might have as many as 15 or 20 men — triple the number of Marines left at Moba Khan.

Paz tells his radioman to get ahold of Nevins. But all they hear is static. Paz tries to maintain his composure. What about Meador? If they can reach him, there's a decent chance of finally getting some air cover. Again, no response; the radio is dead. "Get that up," Paz screams at his radio operator, "or we're done!"

IV One of the ironies of McChrystal's directive is that the military's ability to plan and execute precision strikes — with minimal loss of civilian life — has never been better. In fact, the Air Force has a set of tools and protocols so finely tuned that even Human Rights Watch praised its "very good record of minimizing harm to civilians" during the height of the 2008 bombing campaign. But under the new rules, air strikes became a tactic of last resort — no matter how methodically targeted. So planned assaults against fixed targets have become rare.

A few days before the standoff at Moba Khan, I got to see how the target-approval system works. The demonstration took place inside a top-secret annex to the Combined Air and Space Operations Center — the heart of US air operations — located on the same base where Grasso and Flor are stationed. (In exchange for access to the facility, I agreed to withhold some details, like certain names and its exact location.)

Military drones over Afghanistan are subject to the same rigorous target-approval protocol as piloted fighters and bombers.

Photo: Courtesy of US Air Forces Central

An officer, I'll call him Paul, walks me through the process. It starts with "targeteering," figuring out where a pilot should attack. Just getting GPS coordinates or an overhead image isn't good enough. GPS is unreliable when it comes to altitude. And landscape and weather conditions can throw satellite pictures off by as much as 500 feet. "Even with Gucci imagery, there's always errors," Paul says. He points to a pair of screens: On the right side is an aerial image of a building. On the left, two satellite pictures of the same place — taken from slightly different angles — flicker in a blur. Paul hands me a pair of gold-rimmed aviator glasses. I put them on, and those flickers turn into a single 3-D image. Paul compares the 2-D and 3-D images, then picks exactly where the building should be hit. Depending on elevation, adding a third dimension can shrink a 500-foot margin of error down to 15 feet.

Step two is "weaponeering," deciding how to strike the target. Paul clicks on a piece of software that simulates what a particular weapon will do to a structure. To demonstrate, Paul punches up a simple 3-D representation of an adobe building, similar to the ones in the Moba Khan compound. Then he picks how he'll attack it: an F-15E jet armed with a 500-pound satellite-directed bomb. He picks a corner of the roof as his aim point. The program starts running. In a few seconds, it predicts how the attack is most likely to unfold: Only one wall of the building will be left standing.

Other tools calculate how far a weapon's blast and shrapnel will spread and how many people might be in the area at a given time of day. Paul's team also checks a Google Earth map highlighting all the known hospitals, mosques, graveyards, and schools in Afghanistan. If the target is too close to one of these, ground commanders will scrub the mission.

A worldwide network backs up the targeteers. Spy drones, flown remotely by pilots in Nevada, keep watch on an area to confirm that militants are really around and women and children aren't. That footage is beamed around the world to imagery analysts, who scour the video for civilians and off-limits sites. "We're always finding a mosque or two," Paul says. Finally, military lawyers and intelligence specialists compare the drone's views to radio intercepts, informants' tips, and intel from recon teams on the ground.

Taken together, it might be the most precise, most sophisticated system for applying lethal force ever developed — the Platonic ideal of how an air war should be run. The problem, of course, is that all these steps take time — time to wait and watch silently through a drone's eyes, time to marry up the images, time to run the simulations.

Such strikes used to take place a few times a week — despite the fluid nature of the Afghan counterinsurgency. But under McChrystal, the system has become even more rigorous. To get a strike approved in advance, ground commanders now need to provide the top brass with multiple sources of intelligence showing that there are only militants and not civilians, proof that there's no other way to go after a target, and even a plan to justify the bombing to the locals. Not surprisingly, these requirements rarely come together.

The only bombs that get dropped these days are those used to protect "troops in contact" — soldiers currently engaged in a firefight. But because these events are sporadic and unpredictable, there just isn't time to involve Paul and his team. This creates something of a paradox: The most precise, humane air strikes are off limits, while the most risky, least controllable bombing runs continue (albeit under tighter restrictions).

When I visit, Paul and his crew sit idle, passing the time running and rerunning simulations. Meanwhile, the real war rages hundreds of miles away.

V Paz and his four fellow Marines try to hold back the Taliban assault — without support from the air and without the rest of their squad. The radio operator frantically screws and unscrews his antenna, trying to bring his gear back to life. Suddenly, a bit of the wall behind him explodes: sniper shots.

After five minutes, the radio inexplicably crackles back to life. Paz exhales in relief. "We're taking enemy fire," he says into the handset. "Be advised, have only a fire team and myself."

A half mile away, inside the schoolhouse, Meador tells his team to get the mortars and artillery ready. (It's fairly easy to call in mortars, artillery, and attack helicopters — even though those are less precise than strikes from a fighter jet. The difference, of course, is the size of the blast.) "If you want us to shoot something, let us know," the captain says. Paz does. Lots of things, actually. Starting with that sniper. "Stand by for direction and distance," he says. He gives the coordinates. A flurry of 60-millimeter mortar rounds fly at his enemies, each landing with a thud.

Paz asks Meador to fire again — this time on the Taliban's exit routes. Meador calls in artillery, shot from a mobile firebase in the western desert. The shells hit the ground and send shock waves through the Marines' chests. Then more mortars. Then artillery again. But every time, the pattern is the same: a brief pause, followed by more sniper shots. What they need is a 500-pound bomb.

With the situation worsening, a pair of Harrier jets are summoned. J. P. Larkin, an air controller at the schoolhouse, tells the pilots to survey the scene at Moba Khan. The Harriers swoop past the tree line and the compound, transmitting video back to the schoolhouse. Larkin taps his tablet computer with a stylus and a pair of still images appear onscreen. He's using a system called PSS-SOF — short for Precision Strike Suite for Special Operations Forces, and pronounced "piss off." It's a kind of dumbed-down version of the tools used by targeteers.

Larkin has the jets point their cameras at a small, square building on the compound's northern edge, where they think the sniper is. The approach looks good, so Larkin radios back to the battalion command post, about 10 miles away, to get approval for the Harriers to bomb the sniper's perch. The battalion calls back to the commanding officers at the brigade headquarters, who check with headquarters in Kabul and, finally, the main air operations center.

"Sir," one of Meador's lieutenants asks, "you want to drop this bomb, right?"

Meador picks up a plastic bottle, puts it up to his mouth, and spits tobacco juice inside. He glances around the room, then takes another look at the Harriers' videofeed. "I'm still trying to develop the situation," he says.

After more than a day of combat, Meador is pretty sure he's got the Taliban's tactics figured out. First they go to the tree lines and the cornfields to shoot. Then they regroup inside the compound and let the sniper go to work. The key is to drop the bomb when the militants are in the building.

Larkin, holding the radio handset to his ear, receives word from the battalion. "Mission's approved," he tells the other Marines. Meador's still not convinced the time is right, though. Under McChrystal's rules, he'll likely have just the one chance to take out the sniper. He rubs his temple. "I don't want to waste this," he says. "How much longer has this guy got?"

Larkin checks with the pilots. Bad news: The Harriers are running low on fuel and have only 10 minutes before they have to leave.

Meador goes over the bomb's detonation pattern one more time with Larkin. It'll be on a timer, puncturing the building's roof, then detonating. That should bring down the whole place, crushing the sniper and anyone else inside.

After all the planning, waiting, and hand-wringing, this is the best they can do.

At 11:50, Meador finally gives the OK. Larkin tells the Harriers: "Cleared hot."

"It's off," Larkin announces to the room. "Twenty-eight seconds."

Larkin and Meador stare at the Harrier's videofeed, which stays fixed on the target. The seconds tick by. Then a plume of smoke shoots from the hostile compound. Dust engulfs the screen. "Fuck your building, bitch!" Larkin screams. Direct hit.

Moba Khan goes quiet.

"Receiving no more fire," Paz radios Meador.

Seventeen minutes pass. Then the AKs open up again. Followed by a sniper. Did they miss? Is this a second sniper? Nobody knows.

There won't be a second run, so Meador calls in more mortars, artillery, and helicopters.

Eventually Meador is able to reinforce Moba Khan, and the Taliban back off. After a third day, he deems it quiet enough to bring Paz and his squad back to the schoolhouse. But Meador sends another squad to replace them. And then another squad to replace that one. At press time, attacks in the Mian Poshteh area have diminished, and Echo Company has returned home. As a new crew of Marines branches out to work with the population, they know that the militants could ambush them at any time—with no guarantee of a 500-pound backup.

Contributing editor Noah Shachtman (wired.com/dangerroom) wrote about defense secretary Robert Gates in issue 17.10.