It was quiet in Nogales, Ariz., before the soldiers appeared. A line of armored vehicles rumbled through the morning stillness of the dusty border town, past its fading Old West–style storefronts and groups of curious locals who stepped into the autumn air to watch the convoy roll to a stop. American troops leaped to the pavement, clad in helmets, combat boots and camouflage fatigues. Wiping sleep from their eyes, the soldiers sized up their task: welding coils of razor wire atop the city’s 20-ft.-tall border fence with Mexico.

Everything felt out of place. The Army’s 104th Engineer Construction Company, based at Fort Hood, typically builds roads for hulking military vehicles in remote combat zones like Iraq and Afghanistan. But since Election Day, Nov. 6, they’ve been working on the border fence in Nogales, down the street from Kory’s bridal store. It isn’t a mission the troops are trained or equipped to do: the seven bulldozers, two excavators and other heavy equipment they hauled from central Texas have proved useless. Instead, they have been figuring it out on the fly, executing orders handed down by the Commander in Chief, President Donald Trump.

On one level, those orders seemed straight­forward: protect the U.S. against what Trump calls “an invasion” by a caravan of impoverished Central American migrants traveling north through Mexico. But the soldiers don’t plan to meet the caravan with force. In fact, they say, doing so would be illegal. Since the Posse Comitatus Act of 1878, the U.S. military has been forbidden to take part in domestic law enforcement. Instead, the 104th Engineer Construction Company is doing its best to provide planning assistance, engineering support, equipment and resources to the Department of Homeland Security.

Razor wire is used to help protect a shipping container holding guns and sensitive material. Meridith Kohut for TIME

Soldiers eat dinner in the chow tent, where a Thanksgiving meal would be served, in Sunglow City, an outpost constructed in Tucson, Ariz. Meridith Kohut for TIME

More than 100 units of heavy equipment, including armored Mine-Resistant Ambush Protected vehicles, sit parked, mostly collecting dust under the desert sun. There’s little chance they will be used here. Meridith Kohut for TIME

Similar scenes have played out across the Southwest since Trump issued his orders on Oct. 26. Some 7,000 active-duty troops began to flood border communities from San Diego to Brownsville, Texas, a deployment that equals the troops fighting ISIS in Iraq and Syria. Not since the days when General John “Black Jack” Pershing pursued the Mexican revolutionary Pancho Villa in 1916 has a comparable number of active-duty soldiers converged along the southern frontier for a mission.

Trump is fond of saying you can’t be a country without a border. But what has the President’s ­deployment shown us about who we are as a nation in 2018? Three days of observing, talking and shivering with military units in Arizona shows a country not defined by its border but deeply divided by it: we remain uncertain about the place of immigrants in our communities, what’s needed to protect ourselves and how to apply our values to our politics.

The confusion comes at a price. The estimated cost of the border deployment is expected to total more than $220 million, U.S. officials say (outside estimates are somewhat lower). Critics deride the mission as a political stunt that served no purpose other than to rally Trump’s base ahead of the elections. “It’s a waste of time,” says Chuck Hagel, a former U.S. Defense Secretary, Republican Senator from Nebraska and Vietnam War veteran. “It’s clear to me that he’s using the military as political pawns, which is completely irresponsible.”

But the midterms are over now, Trump has stopped tweeting about the caravan, and the troops are still here, still out of place. On short notice, they flew from their bases to the border and built tent cities from nothing in the middle of nowhere. They established running water, electricity, working toilets. And they’re prepared to stay for weeks, patiently waiting, as the caravan inches closer and their own families celebrate Thanksgiving, and possibly Christmas, back home without them.

Helicopters fly over rapidly assembled tents used for army sleeping quarters. Meridith Kohut for TIME

Responding to the caravan took on renewed urgency for Trump on Oct. 19, when he saw television footage of thousands of migrants storming Mexico’s border gate with Guatemala. By then, the President had grown increasingly agitated at the limits of his power to stop illegal crossings. His vision of forcing Mexico to fund a massive border-wall construction project was stymied first by geopolitical realities, and then by Congress. As the midterm elections approached, he was itching for a way to show voters he was tough on the border and to goad Democrats into a debate on immigration policy.

The images presented an opening. Trump demanded U.S. military officials come up with a plan to prevent something similar from happening at U.S. ports of entry, and midlevel officials at Homeland Security and the Pentagon began drafting a plan. On Oct. 25, Trump fired off a 6 a.m. tweet: “I am bringing out the military for this National Emergency. They will be stopped!”

The topic became a fixture at the President’s campaign rallies, where “Build the wall” made for a crowd-­rousing slogan and references to “birthright citizenship” reliably drew boos. National exit polls found the share of voters worried about immigration was about 23%, and Trump’s closing midterm argument targeted them, even as Republican strategists suggested he focus on the healthy economy instead. “At this very moment, large well-­organized ­caravans of migrants are marching toward our southern border. Some people call it an invasion,” Trump said Nov. 1, less than a week before Election Day. “These are tough people in many cases: a lot of young men, strong men and a lot of men that maybe we don’t want in our country.”

A USO RV, where soldiers can hang out, watch movies and charge cell phones, at Sunglow City. Meridith Kohut for TIME

While members of the caravan rested their blistered feet in Mexico City in the first week of November, Trump ordered the U.S. military to fan out across the Southwest. Army Captain Charles Matthews, 40, had less than a week to prepare his troops for the deployment. Usually such orders come with four or five months’ lead time, but Matthews didn’t have that luxury. He tasked First Sergeant Brian Rethage, 40, with going through the company’s rolls and figuring out who was available to go. After weeding out those with medical or other issues, Rethage came up with about 130 deployable troops. Matthews broke the news to those soldiers: they were going to Arizona and might not be back in time for the holidays.

The next problem: deciphering what the mission was exactly. Unclear on the details, Matthews brought what he thought he might need: bulldozers, excavators, scrapers, rollers and graders, all loaded onto semitrucks and sent off on the 888-mile trek from Fort Hood to Davis-­Monthan Air Force Base in Tucson, Ariz. “We made an assumption that we would be doing horizontal earthwork: improving roads, you know, something in our wheelhouse,” he says. “We came out here and found we were wrong.”

It turned out the mission was to tighten security at two border locations in Nogales, the DeConcini Crossing and the Mariposa Crossing. The border fence splits the city in two: one side of town is in the U.S., the other is in Mexico. It’s made up of 20-ft. steel slats that snake up hills and down into valleys, running parallel to city streets. Instead of land movers and construction equipment, Matthews needed miles of razor wire, brackets to hang the wire from, welding machines to secure the brackets and construction lifts to get his soldiers up and down.

Getting the material and equipment was just the start. Only eight of 130 troops knew how to weld. (“By design,” he says. “My company is not trained to weld.”) The baskets on the cherry pickers used to lift the soldiers to the top of the fence weren’t suitable for the work, so the troops had to construct new ones from discarded wooden pallets. Then the team realized the sparks from the welder were falling on taxis parked behind the fence, on the Mexican side of the border. So Matthews’ troops draped a 12-ft.-long wet rag from the basket to swallow the sparks. “This is a nonstandard engineering mission,” Matthews says. “But we’re engineers. We solve problems.”

From sunrise to sundown, the company welded the brackets and affixed the razor wire, under the watch of bemused residents. In the past, the fence never stopped the people of Nogales from moving back and forth across the border for shopping, ­doctors appointments, family visits or daily work. The locals have a saying: “Ambos Nogales.” In English it means “Nogales Together.” But the presence of the troops underscored the permanence of the fence and what it has come to represent.

Soldiers train in combat lifesaving techniques at Sunglow City, the newly erected Army outpost in Tucson, on Nov. 13. Meridith Kohut for TIME

Soldiers pass their downtime by throwing a football around, texting their partners, exercising or waiting for the outdoor mess hall to open. Meridith Kohut for TIME

Each day, the migrant caravan trudges nearer. It began in the Honduran city of San Pedro Sula on Oct. 12 and reached the Mexican capital nearly four weeks later, populated by migrants traveling through rain and heat. The caravan’s 5,000 ­people—many of them parents, children and unaccompanied ­minors—say they are fleeing violence and poverty in Central America. They travel together because there’s safety in numbers: migrants have been kidnapped, raped or even killed. Two other, smaller caravans have since formed to follow the first. Many members will split from the group in Mexico. Others will travel the remaining miles to reach the U.S. border and apply for asylum.

To some in Nogales, they would be welcome. It is ironic, officials there say, their city needs more, not less, traffic from Mexico right now. Trump’s crackdown has slowed the number of people crossing the border into Nogales to a trickle. In the past 10 years, annual pedestrian crossings into Nogales have dropped to 2.7 million from 7.7 million. That lack of foot traffic has resulted in the closure of some 15 stores in and around Morley Avenue, the city’s main commercial drag, the officials say.

Santa Cruz County supervisor Bruce Bracker closed his family’s retail shop in 2018; it had been open for 94 years. He argued that the years-long Border Patrol staffing shortages at Southwest ports of entry posed the largest security threat to border towns, such as Nogales. “The connotation of razor wire in our city is depressing. It looks like a prison,” Bracker says. “I get that illegal immigration is a problem. It needs to be addressed. But America is supposed to set an example for the world on these sorts of issues. Shutting down asylum claims and deploying the military to the border isn’t the solution. It’s the beginning of another problem.”

Military police stand guard as other members of the 104th Engineer Construction Company work to heighten security of the border wall. Meridith Kohut for TIME

The members of the 104th Engineer Construction Company avoid such ­debates. They aren’t the only troops on hand. Military police stand ready to defend the engineers should something go awry. But they don’t anticipate facing any enemy other than the weather, the fragility of their equipment or the lure of fast-food restaurants. “We’re not here to stop the migrant caravan,” says Colonel Larry Dewey, commander of the 16th Military Police Brigade from Fort Bragg, N.C. “We’re here to make sure they come through in an orderly manner.”

The Nogales detachment is part of a 1,500-troop deployment in Arizona. Most of them are stationed 75 miles from Nogales at Davis-­Monthan Air Force Base, where they’ve constructed a 77-sq.-acre outpost called Sunglow City. That base, if you squint hard enough, is indistinguishable from ones like it in Iraq or Afghanistan, a logistical feat sprawled across the desert. The Army spread 1,700 tons of gravel over an area that features 140 tents, 150 portable toilets, a 20-bed hospital, a gym, laundry service and eight trailers packed with 15 hot showers each. Soldiers can watch TV while they wait their turn.

Cpt. Jacob Riffe, 29, from Augusta, Ga., puts his shoes on after waking up just after dawn inside his unit's tent. Meridith Kohut for TIME

Soldiers of the 104th Engineer Construction Company weld brackets for concertina wire along the border wall. Meridith Kohut for TIME

If it feels like a base on the other side of the world, it’s not. Every day, the troops are reminded they’re deployed deep in their own homeland. Restaurants and bars just outside the base gates are off-limits ­because the soldiers are considered to be on a deployment. Some younger soldiers have been overheard complaining that they are prohibited from going off base to eat at a nearby Chili’s. The Army plans to serve the troops a Thanksgiving dinner—with turkey and trimmings provided by contract caterers—on the base at Davis-Monthan. Soldiers will phone home or Skype with their loved ones. Some are single parents; their children will mark the holiday back home with temporary guardians.

Those who have served in combat operations overseas know any comparison to the ongoing wars is laughable. “This isn’t a deployment,” says Staff Sergeant Tamara Bonner, 38, of Fayetteville, N.C., who served in Iraq and Afghanistan. “We’re carrying out a mission, but this isn’t a deployment.”

Nearby, more than two dozen heavily armored vehicles, including Mine-Resistant Ambush Protected vehicles, sit parked, collecting dust under the desert sun. There’s little chance they will be used here. Troops in Sunglow City often find themselves with little to do. They fill the time throwing a football around, texting their girlfriends, exercising or waiting for the outdoor mess hall to open. But experienced Pentagon hands on base recognize one group that has profited from the vehicles’ dispatch to Sunglow City: the private contractors who were paid to haul them there from Texas.

A soldier walks through a sandstorm at Sunglow City. Meridith Kohut for TIME

Back in Nogales, the soldiers are making steady progress on the wall. Three days after U.S. soldiers started putting up the razor wire in Nogales, their work was put to the test. On Nov. 9, a Mexican man tried jumping the fence through a gap in the wire. U.S. Border Patrol agents immediately responded. The man tried to scramble back over the wall but got entangled in the newly emplaced coils, U.S. Customs and Border Protection confirmed to TIME. As the Border Patrol agents closed in, the man freed himself and made it back into Mexico.

When the mission was announced Oct. 29, it was called Operation Faithful Patriot. Nine days later, the Pentagon quietly scotched that name, wary of its political overtones. It’s now officially known as Operation Secure Line, but privately, some soldiers are jokingly calling it “Operation Border Security”—or Operation B.S.

The U.S. military still doesn’t know which port of entry the caravan is headed for. And even if it comes to Nogales, it’s not clear the work of the 104th Engineer Construction Company will have been for any purpose. On Nov. 14, Defense Secretary James Mattis and Homeland Security Secretary Kirstjen Nielsen visited soldiers working the border mission in Donna, Texas. A soldier there asked Mattis whether they would later have to tear down the razor wire that they put up just days earlier. Mattis replied, “We’ll let you know.” —With reporting by Brian Bennett and Philip Elliott/Washington

Write to W.J. Hennigan at william.hennigan@time.com.