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.

The AP is one of the largest and most trusted sources of independent newsgathering. AP is neither privately owned nor government-funded; instead, as a not-for-profit news cooperative owned by its American newspaper and broadcast members, it can maintain its single-minded focus on newsgathering and its commitment to the highest standards of objective, accurate journalism.