WASHINGTON—President Trump declared a national emergency Friday over border security, bypassing Congress to divert money from elsewhere in the government to pay for additional barriers along the southern border, a move likely to ignite immediate court challenges.

Mr. Trump also signed a bipartisan spending bill that will keep the government funded through the fall and allocates $1.38 billion for 55 miles of border barriers—far less than the $5.7 billion the president had asked for.

Unsatisfied...