The US Supreme Court has said that President Donald Trump can use $2.5bn (£2bn) 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".
Wow! Big VICTORY on the Wall. The United States Supreme Court overturns lower court injunction, allows Southern Border Wall to proceed. Big WIN for Border Security and the Rule of Law!— Donald J. Trump (@realDonaldTrump) July 26, 2019
The president has argued that a new wall would help to curb illegal immigration, which he says is fuelling crime and placing a strain on the economy.
Democrats say they are in favour of border security but the wall would be expensive and ineffective. They argue that Mr Trump has manufactured the border emergency and that the wall has become a symbol of Trump's anti-immigration platform.
On Friday, the US and Guatemala also 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 heading straight for the US.
What has the reaction been to the ruling?
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 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.
What is happening at the border now?
According to US authorities, 104,344 people were arrested along the southwest border in June - a 28% drop from the previous month.
The Trump administration claims the decrease is due to new policies with Mexico to curb migration, including increased security on the Mexican side of the border, and the expansion of a scheme that makes asylum seekers wait in Mexico while their cases are being processed.
However, experts say that reduced migration is also typical during the hot summer months.
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.
The Department for Homeland Security says "we are still in an ongoing border security and humanitarian crisis".
The number of people detained on the US-Mexico border is far lower when compared with the previous decade.
The number fell in President Trump's first year but rose again last year - but even before the increase, when migration numbers were at historic lows, Mr Trump described the situation on the border as a national security crisis.