The US Supreme Court has said that President Donald Trump can use $2.5 billion (£2 billion) of Pentagon funds for a section of wall on the southern border.
The court ruled by five votes to four to block a ruling by a federal judge in California that barred the president from spending the money on the wall.
The wall, dividing the US and Mexico, was Mr Trump’s major campaign promise during the 2016 election.
It is fiercely opposed by Democrats.
The decision by the Supreme Court means that the money will be used for wall projects in California, Arizona and New Mexico.
The court in California had argued that Congress had not specifically authorised the funds to be used for constructing the wall.
In a tweet, Mr Trump described the ruling as a “big victory”.
On Friday, the US and Guatemala signed a deal, under which migrants from Honduras and El Salvador who pass through Guatemala will be required to stop and seek asylum there first, rather than continuing and trying to enter the United States.
US House Speaker Nancy Pelosi said: “This evening’s Supreme Court ruling allowing Donald Trump to steal military funds to spend on a wasteful, ineffective border wall rejected by Congress is deeply flawed. Our Founders designed a democracy governed by the people – not a monarchy.”
The American Civil Liberties Union (ACLU) has vowed to seek an expedited decision from the Ninth Circuit Court of Appeals “to halt the irreversible and imminent damage from Trump’s border wall”.
Gloria Smith, an attorney with environmental group the Sierra Club, which sued to block the funds said: “Today’s decision to permit the diversion of military funds for border wall construction will wall off and destroy communities, public lands, and waters in California, New Mexico, and Arizona.”
Mr Trump declared an emergency earlier this year, saying he needed $6.7bn to build the wall as a matter of national security. However, this figure is far short of the estimated $23bn cost of a barrier along the whole 2,000 miles (3,200km) of border.
Democrats claimed Mr Trump’s decision to declare an emergency exceeded his powers under the US constitution.
About 20 states, along with groups including the American Civil Liberties Union (ACLU) have filed lawsuits to try and stop the president using the emergency declaration to bypass Congress.
Environmental groups have also campaigned against building the wall claiming that it could have a negative impact on wildlife.
In February, Congress approved $1.38bn for the construction of “primary pedestrian fencing” along the Rio Grande Valley in Texas – far less than Mr Trump had sought.
The House of Representatives is also taking legal action to stop the diversion of further funds for the wall project.
According to US authorities, the number of border apprehensions dropped by 28% in June.
The decline follows a record number of apprehensions between ports of entry in May – the highest in over a decade. Drops in migrations are typical during summer but this June saw a sharper decline compared to previous years.
The Trump administration claims the decrease is due to new policies with Mexico to curb migration.
The UN Missing Migrants project reports that 170 migrants have died or are missing on the US-Mexico border so far in 2019 – including 13 children.
Signup for FREE news updates, latest information and hottest gists everyday