With a little help from the Supreme Court and Mexico, US President Donald Trump's fitful crackdown on immigration is finally gaining traction.
Trump has spent his entire presidency promising to stop illegal immigration, shut out asylum seekers and wall off the Mexican border.
The far-reaching policies sparked an avalanche of court challenges, complaints from human rights organizations and derision from opposition Democrats ahead of next year's elections.
Undeterred, Trump has hammered away, making construction of a US-Mexican border wall one of his presidency's centerpieces - and a key part of his 2020 reelection platform.
And this week he celebrated a string of victories.
The latest boost came on Wednesday when the Supreme Court said he could enact severe restrictions on asylum seekers.
The ruling requires would-be refugees to ask for asylum in the first country they visit and only then - if they are rejected - can they attempt to apply in the United States.
The ruling - which has temporary effect while challenges play out in lower courts - shuts out large numbers of people fleeing violence and poverty in Central America. They will now have to apply for asylum in Mexico, rather than head directly to the United States.
Trump's opponents, as well as dissenting Supreme Court Justice Sonia Sotomayor, say the change upends decades of tradition in which the United States, itself founded by waves of often poor immigrants, has welcomed refugees.
But Trump, who argues that economic migrants abuse the system with fraudulent asylum claims, went to herald the "BIG United States Supreme Court WIN for the Border on Asylum!"
"The Southern Border is becoming very strong despite the obstruction by Democrats," he tweeted.
Mexico comes on board
That's far from all.
In July, the Supreme Court backed Trump's move to divert billions of dollars in Pentagon funds to pay for extending or rebuilding stretches of wall on the Mexican border. This lets him circumvent fierce resistance to funding in a divided Congress.
The Pentagon also said this Tuesday that the deployment of 5 500 troops on the border - something that was initially highly controversial - was being extended for the coming year.
While Trump exaggerates the amount of wall-building activity, there's no question that momentum is gradually shifting his way.
"The Wall is going up very fast despite total Obstruction by Democrats in Congress, and elsewhere!" he tweeted on Wednesday.
Perhaps the most significant shift has happened on the other side of the long, rugged frontier, where the Mexican government has set aside previous hostility to cooperate with Trump.
The change in mood follows threats by Trump to impose trade tariffs on Mexico, even though the two countries are in a free trade agreement together with Canada.
After a meeting with Foreign Minister Marcelo Ebrard this Tuesday, US Vice President Mike Pence "acknowledged the government of Mexico's meaningful and unprecedented steps to help curb the flow of illegal immigration", the White House said.
Mark Morgan, head of the US border patrol service, welcomed "unprecedented support" from Mexico, which he said has deployed 10 000 troops on its own southern border with Central America and 15 000 on the US border.
Proof that the joint crackdown is having an effect is in the numbers, US officials say.
August detentions of undocumented migrants numbered 64 000, down from 82 000 the previous month and 144 000 in May, Morgan said. Mexico, he said, has apprehended 134 000 people so far this year, compared to 83 000 in all of 2018.
Democrats use the immigration issue to paint Trump as heartless, even racist. But the president feels he's on the right track.
On Monday, as streams of Bahamians tried to exit islands ravaged by Hurricane Dorian, Trump made clear the United States would eye this latest group of asylum seekers skeptically.
"I don't want to allow people that weren't supposed to be in the Bahamas to come into the United States, including some very bad people and some very bad gang members and some very, very bad drug dealers," he said.
The language echoed his long-term characterisation of Central American migrants as potential rapists and gang members.