File photo of the commander of US forces in the Middle East, General John Abizaid (AFP)

LAREDO: They started work in the cool of the morning and moved quickly, uncoiling reel after reel of vicious-looking fencing and tying it with barbed wire to green poles hammered into the ground. Over the course of three days, a gleaming, shoulders-high barrier of concertina-wire emerged like a silver snake along a lush riverbank, stretching as far as the eye could see.

This was the work of 100 or so American troops from the 19th Engineer Battalion, based in Fort Knox, Kentucky .

Rather than finding themselves in a far-off warzone, the soldiers are in Laredo, a busy border town overlooking a stretch of the Rio Grande river in southwest Texas , carrying out controversial orders from President Donald Trump.

He has sent about 5,800 troops to the border to forestall the arrival of large groups of Central American migrants traveling through Mexico and towards the US, in a move critics decry as a costly political stunt to galvanize supporters ahead of midterm elections earlier this month.

Before the election Trump called the matter a "national emergency" and warned that so-called migrant caravans were an "invasion" with "some very bad thugs and gang members." So far at least, the most visible aspect of Trump's deployment is the fence, a visible deterrent and physical obstacle to migrants, designed to corral would-be asylum seekers towards organized points of entry into the US.

Over the weekend, Lieutenant Alan Koepnick's platoon could be seen stringing concertina wire, which is built to snag clothing, along one edge of a quiet riverside park near downtown Laredo.

As families walked dogs, grilled sausages and relaxed, the soldiers mounted the wire, occasionally ripping their camouflaged uniforms on its metal barbs.

Koepnick said some Laredo residents had voiced disquiet about the fencing and the presence of US troops.

"But there's also been a lot of support, people coming in, vets shaking our hands, bringing us cakes, water, things like that," Koepnick told AFP.

About 100 yards (meters) behind him, a group of people on the Mexican side of the river could be seen standing on the bank.

"You'll see people across the river cursing at us in Spanish, throwing bottles at us. But on this side it's more positive," Koepnick said.

He and his soldiers were unarmed, but a group of armed military police officers stood by to provide "force protection." Under US law, the military is not allowed to conduct domestic law enforcement in most cases, so soldiers here will not have any direct interactions with migrants.

Trump created a media whirlwind by sounding the alarm about the migrant caravans before the November 6 elections. He has mainly stopped raising it since, though last week he praised the military's work.

"They built great fencing, they built a very powerful fence," said Trump, who wants to build a hardened wall along the entire 2,000-mile (3,200-kilometre) border.

Laura Pole, a British tourist visiting Laredo for the third time, was less enthusiastic.

"It reminds me of Hitler and the concentration camps," she said, but added: "I really don't know what's the best thing to do."

The border mission has put the supposedly non-political military in an uncomfortable spotlight.

Defence Secretary Jim Mattis has hit back at critics who say the Pentagon should not be doing Trump's political bidding, saying "we don't do stunts".

He visited troops on the border last week and reiterated that their job in the short term was to assist under-resourced Customs and Border Protection (CBP) agents and put up physical obstacles.

But "longer term, it's somewhat to be determined," he said.

After some rank-and-file troops grumbled about the purpose of the mission to US media last week, they are now under strict instructions not to voice personal opinions to the press.

Several soldiers AFP spoke to said their time on the border provided valuable real-world training, albeit without the risks of combat.

"We have a very large group of brand-new soldiers and it's really good for them," Corporal Samuel Fletcher said, citing a chance for the green troops "to do real work and put their skills to use."

In Laredo, large groups of migrants from the caravans in Mexico had not arrived.

Instead they were mainly headed to Tijuana, about 1,300 miles away in San Diego, where authorities say more than 3,000 have already arrived.

Still, a CBP agent, who was not authorised to give his name, said he was glad of the military assistance as each day, "hundreds" of migrants attempt to cross the approximately 30-mile stretch of border he patrols.

The military deployment is set to wrap up December 15 and it is not clear what will become of the wire fencing.

Already, the winds whistling down the Rio Grande valley are strewing trash, clothing and plastic bags along the jagged wire.

"Nobody seems to know when it's coming down. It's not really our decision," said Koepnick.

"If we are told to take it down, we will take it down with a smile on our faces, like good soldiers."