The Senate approved an $18 billion extension to benefits on Thursday, sending the bill to the president. The legislation had been stalled in the Senate for weeks, causing a halt to benefits for hundreds of thousands of unemployed workers.

The legislation approved Thursday night provides benefits retroactively to cover that gap.

The package restores unemployment insurance and COBRA healthcare plan benefits that had lapsed since the end of March.

Obama signed the bill after returning from a Democratic National Committee fundraiser in Miami. The president landed in Washington at 9:51 p.m. and the office of the press secretary sent out a statement indicating Obama had signed the extension by 10:15.

Senators had struggled to pass the extension before leaving for a two-week recess, despite the benefits having expired at the end of that month. Sen. Tom CoburnThomas (Tom) Allen CoburnMr. President, let markets help save Medicare Pension insolvency crisis only grows as Congress sits on its hands Paul Ryan should realize that federal earmarks are the currency of cronyism MORE (R-Okla.) had led Republicans in objecting to the extension until spending offsets could be found to fund it. Democrats had said the spending was for emergency purposes, and didn't need to be subjected to pay-as-you-go rules.

The measure Obama signed into law extends benefits until June 2, while lawmakers work on passing a longer-term extension for the benefits.