Mauricio Lima for The New York Times

CAMP LEATHERNECK, Afghanistan — It has taken the United States years to amass the mountains of gear piled up at huge bases like Camp Leatherneck in southern Afghanistan. It is the job of logistics experts like First Lt. Rachel Opperman, 23, to bring it all back home.

As the war here draws to a close and the American military begins to reduce its forces, it also has to send back most of its equipment, an immense logistics effort already under way and spanning half the globe.

Lieutenant Opperman, a Marine from Pittsburgh who is known here as the Queen of the Sort Lot, runs one of the big receiving yards, a dusty, 12-acre lot that is taking in superfluous equipment as bases shrink, close or are transferred to the Afghan forces all over the southwest of the country.

One recent morning here, Marines ranged slowly in the 100-degree heat under her direction, packing piles of supplies into 5-foot-by-5-foot boxes. Forklifts shifted the boxes onto pallets electronically tagged so their journeys could be tracked to Marine bases or depots in the United States and Japan, bringing order to the chaos of a staggeringly complex 24-hour reverse supply chain operation.

There were stenciled racks for axles, fax paper, filters, hoses, sheets of ballistic glass and fenders off mine-protected vehicles.

A wooden sign at the gate kept score: “Recovered to date: $160,937,622. Pallets built: 805. Containers built: 613.”

“We will take almost anything,” Lieutenant Opperman said. “We take it, and we figure out where it has to go.”

The international military mission here still has almost two and a half years before the 2014 withdrawal deadline, and commanders hesitate to discuss openly the details of what is known as the “retrograde” of equipment back to the United States.

The issue is freighted with sensitivities about the United States’ commitment to Afghan security. American commanders do not want to give the Taliban any sense they are already giving up on the fight.

Officials admit that imagery is also a factor. Even as they make decisions about what to pack up, what to leave behind for Afghan forces, or what to abandon or destroy, they want to avoid any echo of the Soviets’ headlong rush out of Afghanistan in the late 1980s, which left the countryside strewed with rusting tanks and guns.

In any case, though, troops are already departing, and military planners are carefully calculating how to extricate the equipment smoothly. In all, officials estimate, they will have to wrangle 100,000 shipping containers of material and 45,000 to 50,000 vehicles like tanks and Humvees from all across Afghanistan.

That is all complicated by the greater expense, and security risk, of shipping things out of Afghanistan, given that fighting is still expected even as the withdrawal takes place.

Col. Jeff Hooks, the senior Marine logistics officer in southwest Afghanistan, said budgetary concerns demanded that the Marines take as much functional equipment back with them as possible. “We have a very, very detailed plan,” he said, slapping a three-inch-thick white binder on his desk called the “Reset Playbook.”

He noted that the Marines’ Afghan withdrawal would be more complicated than their Iraq pullout, even though they had collected less equipment in Afghanistan. The extra difficulty comes largely because of Afghanistan’s special geography: In Iraq, supply routes ran south to Kuwait and the Persian Gulf, but Afghanistan is a landlocked country, and the nearest port — Karachi, in Pakistan — is 600 miles away.

After Pakistan closed its border in November to protest a coalition airstrike that killed 24 of its soldiers, the Marines have mostly flown excess equipment out at a rate of 18 to 24 flights a day. These went directly to the United States or to ports in Kuwait, Oman or elsewhere on the Arabian Peninsula, from which they continued by ship.

Sangar Rahimi contributed reporting from Kabul, Afghanistan.

(Page 2 of 2)

Since Pakistan reopened its borders last month, roads south to Karachi are likely to take the greatest weight of future outbound traffic. Once a backlog of supplies on the route clears north into Afghanistan, about 100 trucks carrying excess equipment are expected to leave Camp Leatherneck daily for Pakistan.

Land routes north through Central Asia and Russia, called the northern distribution network, are likely to be another important exit route for American forces stationed farther north in Afghanistan and for European coalition partners. But the winding road routes, the complicated rail gauges and the greater potential for attack and logjam make them less attractive than the Pakistani route.

In the receiving yards at Leatherneck, other issues involved in the withdrawal were evident. Not far from Lieutenant Opperman’s lot, at the Marine Air Ground Task Force Marshaling Yard, Marines assiduously disassembled a Humvee, cleaning individual parts with rags, air and water so that the vehicle could clear the border agricultural inspection for re-entry into the United States.

Nearby, inside a large tent, green and red folders on tables documented the 30 or so radios stacked across the floor, while outside, mortar tubes and shells were carefully packed into containers.

The Afghan government’s Base Closure Commission takes recommendations from NATO and the Afghan Army to determine which bases to shutter and which the Afghans can run for themselves.

According to a timetable set by President Obama, the United States is to withdraw about 23,000 troops from Afghanistan by October, leaving about 68,000 American troops. There are about 13,000 Marines, down from about 20,000, and the United States has said publicly that this number should fall to around 7,000 by October. Coalition levels in the southwest will be bolstered by the arrival of a second battalion from the Georgian Army.

In the southwest, the number of coalition bases is falling to about 70 from 214 in March.

Out at Delaram II, one of the district bases the United States is shrinking and turning over to the Afghans, troops were pulling up the airfield.

The Afghans said they did not want the base’s airstrip, so First Lt. Carolynn Aranha, a 32-year-old Marine from Oregon, took out about 50 Marines to rip up the 5,412-foot-long area of hard matting, working at night under floodlights to avoid the pounding heat of the day.

Piles of ripped-up mats dotted the camp, and around its edges, bulldozers built a smaller perimeter inside the old four-mile-long fence.

“This all has to go,” Lieutenant Aranha said, pointing to the spot where a big air control tower used to stand. “This will go back to Leatherneck, and back to the U.S.”

A group of Army engineers from Florida was busy dismantling one of the main base headquarters buildings. Corrugated iron roofing was collected in one pile; another comprised mattresses destined to be burned. On the base, there was now only one fire truck left, and most of the camp’s four-wheel-drive trucks had been handed in, so getting around the base was hard. Supplies were such that the Marines even recently had to borrow a bulldozer from the Afghans.

Some of the roughly 2,000 Afghan troops stationed on the base sat in the shade under a tarp, patiently watching the deconstruction going on around them. There have been other observers, as well. In June, apparently testing to see if anyone was still at home, four insurgents crawled up to the outer perimeter to cut the wire. They were shot.

The security situation in the area is still not stable. Farther out from the base, insurgent cells are active, especially along the main east-west highway nearby, where they tend to target commercial convoys, officials said.

The drawdown affects not only the troops, but also the army of civilians who come from all over to find livelihoods at Western bases. Among them is Caleb Amasa, 38, a Kenyan from Nairobi who was emptying the trash near a row of tents at Leatherneck. “If it closes, we will miss it,” Mr. Amasa said. “We want work.”

Though many local Afghan civilians have the same concern, not all will be sad to see the Americans go.

A few miles away in the bazaar in Delaram, a town the Marines once patrolled, Islam Gul, 28, a shopkeeper, said he was glad the Americans were leaving. About a week earlier, a close relative, an engineer, was wounded in the neck by a mine explosion aimed at a joint American-Afghan patrol.

“They are foreigners and infidels,” Mr. Gul said by telephone. “It is good if they hand over the base to Afghan forces. They were not bothering us much, but we are happy to hear they are leaving the area.”

Sangar Rahimi contributed reporting from Kabul, Afghanistan.