WASHINGTON, Sept 9 (Reuters) - The Trump administration on Monday credited Mexico and Central American countries with helping to cut U.S. border arrests by nearly 60% from a record high earlier this year but then lashed out at a federal judge for ruling against a strict anti-asylum policy.

With President Donald Trump's anti-immigration policy shaping up as an issue in his 2020 re-election campaign, Mark Morgan, the acting commissioner of U.S. Customs and Border Protection, said that 64,000 people were detained or turned back at the southwest border in August. That was down 22% from July and 56% from a high mark in May.

Even so, the total was the highest for any month of August in more than a decade, as Central American migrants have headed north in record numbers, many seeking asylum from impoverished countries with some of the highest murder rates in the world.

A decade ago, migrants were mostly Mexican. But in recent years they have been overtaken by Central Americans, mostly from the so-called Northern Triangle countries of Guatemala, Honduras and El Salvador.

The Trump administration has been pressuring all of those countries to do more to keep people from reaching the U.S. border, threatening Mexico with tariffs unless it complied.

The United States has persuaded Guatemala to become a so-called safe third country that would accept asylum-seekers, though the deal has yet to be ratified by Guatemala's government, in a bid to reduce the strain on the United States. Washington is working with Honduras on a similar agreement.

The United States has failed to persuade Mexico to do the same. Mexican Foreign Minister Marcelo Ebrard reiterated Mexico's rejection of the status on Monday after Morgan said talks were ongoing for a "cooperative agreement" with Mexico to help stem the tide of migrants.

In the meantime, Mexico has agreed to keep Central American asylum-seekers just south of the U.S. border pending their U.S. court appointments and has deployed National Guard officers to halt them.

Ebrard is to meet with U.S. officials on Tuesday to discuss Mexico's efforts. He said last week that Mexico does not expect the United States to threaten tariffs at this time.

"Right now Mexico has been doing a great job for us, and, frankly, we're very appreciative, but we've also been very, pretty rapidly changing the regulations, the rules," Trump told reporters at the White House.

Earlier on Monday, a U.S. judge dealt Trump a setback, ruling that an injunction against a restrictive rule on asylum-seekers should apply nationwide.

The rule, unveiled on July 15, requires most immigrants who want asylum in the United States to seek asylum first in a third country they had traversed on their way.

San Francisco-based U.S. District Judge Jon Tigar had previously issued a nationwide injunction blocking the rule. But the 9th U.S. Circuit Court of Appeals narrowed it to only border states within its jurisdiction - California and Arizona - and sent the question back to Tigar.

On Monday, Tigar ruled it should apply across the entire border, pending a trial on the underlying legality of the Trump administration rule.

In a statement on Monday evening, the White House said the ruling "is a gift to human smugglers and traffickers," adding that the administration hopes the Supreme Court will set aside the injunction in its entirety.

Morgan criticized Tigar for his ruling and what he called "unprecedented judicial activism." He lamented that with each new administration policy to "address this crisis, we end up getting enjoined. It's very, very frustrating, but we're just going to keep going."

Opponents of Trump's immigration policy praised the judge's ruling, saying that previously, asylum-seekers could be arbitrarily barred, based on where they happened to cross the border.

"Sadly, while this ruling removes a major hurdle, far too many obstacles remain," Melissa Crow, an attorney with the Southern Poverty Law Center, said in a statement. (Reporting Alexandra Alper and Steve Holland in Washington; Additional reporting by Mica Rosenberg and Andrew Chung in New York and Frank Jack Daniel in Mexico City; Writing by Daniel Trotta; Editing by Howard Goller, Dan Grebler and Lisa Shumaker)

Our global editorial team of more than 50 journalists and about 250 freelancers covers the world’s under-reported stories at the heart of aid, development, women’s and LGBT+ rights, human trafficking, property rights, and climate change.