WASHINGTON (AP) — Senate leaders raced to unravel last-minute snags Wednesday and win passage of an unparalleled $2 trillion economic rescue package steering aid to businesses, workers and health care systems engulfed by the coronavirus pandemic.

The measure is the largest economic relief bill in history, and both parties’ leaders were desperate for quick passage as the virus took lives and jobs by the hour.

Insistently optimistic, President Donald Trump said of the greatest public-health emergency in anyone’s lifetime, “I don’t think its going to end up being such a rough patch” and anticipated the economy soaring “like a rocket ship” when it’s over. Yet he implored Congress late in the day to move on critical aid without further delay.

The package is intended as relief for an economy spiraling into recession or worse and a nation facing a grim toll from an infection that’s killed nearly 20,000 people worldwide. Treasury Secretary Steven Mnuchin, asked how long the aid would keep the economy afloat, said: “We’ve anticipated three months. Hopefully, we won’t need this for three months.”

Underscoring the effort’s sheer magnitude, the bill finances a response with a price tag that equals half the size of the entire $4 trillion annual federal budget.

“A fight has arrived on our shores,” said Senate Majority Leader Mitch McConnell. “We did not seek it, we did not want it, but now we’re going to win it.”

“Big help, quick help, is on the way,” said Senate Minority Leader Chuck Schumer.

But the drive by leaders to speed the bill through the Senate was slowed as four conservative Republican senators demanded changes, saying the legislation as written “incentivizes layoffs” and should be altered to ensure employees don’t earn more money if they’re laid off than if they’re working.

Complicating the standoff, Sen. Bernie Sanders of Vermont, whose campaign for the Democratic presidential nomination has flagged, said he would block the bill unless the conservatives dropped their objections.

“What I am saying is that two can play the same game,” Sanders told The Associated Press. “This is most certainly not the bill that I or any other progressive would have written,” he said, but added that he supports it in the main, given the severity of the crisis.

Other objections floated in from New York Gov. Andrew Cuomo, who has become a prominent Democrat on the national scene as the country battles the pandemic. Cuomo, whose state has seen more deaths from the pandemic than any other, said: “I’m telling you, these numbers don’t work.”

Democratic presidential candidate Joe Biden said the package “goes a long way.” He said it will require strong oversight to ensure the wealthy don’t benefit at the expense of workers and proposed forgiving at least $10,000 of student loan debt as part of the federal response.

McConnell and Schumer hoped passage of the legislation in the Republican-led Senate would come by the end of the day. Stocks posted their first back-to-back gains in weeks as the package took shape over the last two days, but much of Wednesday’s early rally faded as the hitch developed in the Senate. The market is down nearly 27% since setting a record high a month ago.

Senate passage would leave final congressional approval up to the Democratic-controlled House. Speaker Nancy Pelosi, D-Calif., said the bipartisan agreement “takes us a long way down the road in meeting the needs of the American people” but she stopped short of fully endorsing it.

“House Democrats will now review the final provisions and legislative text of the agreement to determine a course of action,” she said.

House members are scattered around the country and the timetable for votes in that chamber is unclear.

House Democratic and Republican leaders have hoped to clear the measure for Trump’s signature by a voice vote without having to call lawmakers back to Washington. But that may prove challenging, as the bill is sure to be opposed by some conservatives upset at its cost and scope. Ardent liberals were restless as well.

White House aide Eric Ueland announced the agreement in a Capitol hallway Wednesday, shortly after midnight, capping days of often intense haggling and mounting pressure. The wording of some final pieces of the agreement need to be completed.

The sprawling, 500-page-plus measure is the third coronavirus response bill produced by Congress and by far the largest. It builds on efforts focused on vaccines and emergency response, sick and family medical leave for workers, and food aid.

It would give direct payments to most Americans, expand unemployment benefits and provide a $367 billion program for small businesses to keep making payroll while workers are forced to stay home.

One of the last issues to close concerned $500 billion for guaranteed, subsidized loans to larger industries, including a fight over how generous to be with the airlines. Hospitals would get significant help as well.

McConnell, a key negotiator, said the package will “rush new resources onto the front lines of our nation’s health care fight. And it will inject trillions of dollars of cash into the economy as fast as possible to help Americans workers, families, small businesses and industries make it through this disruption and emerge on the other side ready to soar.”

Five days of arduous talks produced the bill, creating tensions among Congress’ top leaders, who each took care to tend to party politics as they maneuvered and battled over crafting the legislation. But failure was never an option, which permitted both sides to mark big wins.

“That Washington drama does not matter any more,” McConnell said. “The Senate is going to stand together, act together, and pass this historic relief package today.”

The bill would provide one-time direct payments to Americans of $1,200 per adult making up to $75,000 a year, and $2,400 to a married couple making up to $150,000, with $500 payments per child

A huge cash infusion for hospitals expecting a flood of COVID-19 patients grew during the talks at Schumer’s insistence. Republicans pressed for tens of billions of dollars for additional relief to be delivered through the Federal Emergency Management Agency, the lead federal disaster agency.

Democrats said the package would help replace the salaries of furloughed workers for four months, rather than the three months first proposed. Furloughed workers would get whatever amount a state usually provides for unemployment, plus a $600 per week add-on, with gig workers like Uber drivers covered for the first time.

Schumer said businesses controlled by members of Congress and top administration officials — including Trump and his immediate family members — would be ineligible for the bill’s business assistance.

The New York Democrat immediately sent out a roster of negotiating wins for transit systems, hospital, and cash-hungry state governments that were cemented after Democrats blocked the measure in votes held Sunday and Monday to maneuver for such gains.

But Cuomo said the Senate package would send less than $4 billion to New York, far short of his estimate that the crisis will cost his state up to $15 billion over the next year. More than 280 New Yorkers have died from the virus, a death toll more than double that of any other state.

Pelosi was a force behind $400 million in grants to states to expand voting by mail and other steps that Democrats billed as making voting safer but Republican critics said was political opportunism. The package also contains $15.5 billion more for a surge in demand for food stamps.

Republicans won inclusion of an “employee retention” tax credit that’s estimated to provide $50 billion to companies that retain employees on payroll and cover 50% of workers’ paychecks. Companies would also be able to defer payment of the 6.2% Social Security payroll tax.

A companion appropriations package ballooned as well, growing from a $46 billion White House proposal to more than $300 billion, which dwarfs earlier disasters — including Hurricane Katrina and Superstorm Sandy combined.

To provide transparency, the package is expected to create a new inspector general and oversight board for the corporate dollars, much as was done during the 2008 bank rescue, officials said.

Europe is enacting its own economic recovery packages, with huge amounts of credit guarantees, government spending and other support.

Germany alone, Europe’s biggest economy, has agreed to commit over 1 trillion euros ($1.1 trillion) in fiscal stimulus and support — roughly 30 percent of that nation’s entire annual output.

France, Spain and Italy have launched similar programs. The European Union has suspended limits it imposes on member countries’ borrowing and deficits, freeing them to spend more.

Some of Europe’s fiscal stimulus kicks in automatically without any new legislation due to social welfare safety nets that are more extensive than in the U.S.

For most people, the new coronavirus causes mild or moderate symptoms, such as fever and cough that clear up in two to three weeks. For some, especially older adults and people with existing health problems, it can cause more severe illness, including pneumonia, or death.

In the United States, more than 55,000 people have been sickened and more than 800 have died.

Associated Press writers Lolita C. Baldor, Zeke Miller, Mary Clare Jalonick, Ricardo Alonso-Zaldivar, Alan Fram and Padmananda Rama contributed to this report.