Story highlights Obama signed the bill into law Thursday afternoon

The bill ended up getting broad support

(CNN) Congress cleared a bill Wednesday to fund the government and the federal response to Zika, avoiding a potentially embarrassing government shutdown just weeks before the election.

The House and Senate approved the measure -- which would fund federal agencies through December 9 -- with just two days before federal agencies were set to run out of money. Obama signed the bill into law Thursday afternoon, before departing for Israel.

Once leaders resolved the final sticking point -- finding a mechanism to approve money for the city of Flint, Michigan, after its water system was contaminated with lead -- members of both parties were eager to wrap up votes and head home to campaign in the final sprint to the November election. Once bipartisan leaders agreed to add an amendment to a separate water infrastructure bill earmarking funds for Flint there was quick agreement to approve the spending bill.

After weeks of negotiation and stalemate, the Senate approved the so-called "continuing resolution" or CR with broad support, passing 72-26.

A few hours later the House followed suit and approved the bill, 342-85.

Read More