A federal judge in California has blocked President Donald Trump from building sections of his long-sought border wall with money secured under his declaration of a national emergency.

U.S. District Judge Haywood Gilliam Jr. on Friday immediately halted the administration’s efforts to redirect military-designated funds to build sections of wall on the Mexican border.

His order applies to two planned projects to add 51 miles of fence in two areas.

Gilliam issued the ruling after hearing arguments last week in two cases. California and 19 other states brought one lawsuit; the Sierra Club and a coalition of communities along the border brought the other.

At stake is billions of dollars that would allow Trump to make progress on a signature campaign promise heading into his campaign for a second term.