WASHINGTON—Congress approved a measure Monday to fund the government for about three weeks and halt a three-day shutdown, after Senate Democrats accepted GOP leaders’ assurance that they would bring an immigration bill to the floor in the coming weeks.

The House, as expected, then followed suit and approved the bill, 266-150. President Donald Trump signed the bill Monday night, effectively ending the shutdown.

The...