The Senate voted early Friday morning to pass a $1.3 trillion measure that would fund the government for the next six months, clearing the bill for President Trump’s signature ahead of a Friday midnight deadline and avoiding a partial government shutdown.

The 65-32 vote came after Sen. Rand Paul, R-Ky., lifted his threat to delay the bill. Paul complained he did not have time to read the 2,232-page legislation, which he said would raise the deficit to $1 trillion this year.

Sen. Jim Risch, R-Idaho, was another hurdle to passage. He demanded that lawmakers remove a provision renaming Idaho’s White Cloud Wilderness after late Democratic Gov. Cecil Andrus, who made unflattering comments about Risch to the local media before he died.

That forced the Senate to quickly pass a measure stripping out the Andrus provision, after the House removed it earlier in the day.

The bill raises federal spending caps and increases spending for both domestic and military programs. The legislation also included many last-minute policy riders negotiated between the bipartisan leaders of the House and Senate.

Those riders included language to bolster reporting to the National Criminal Instant Background Check System and $4 billion for states to battle the opioid epidemic.

Sen. Bob Corker, R-Tenn., complained ahead of the post-midnight vote that it was “ridiculous” that the Senate tends to hold middle- of- the night votes on spending legislation.

He implored Senators to hold the vote Friday morning, but acknowledged that lawmakers were eager to catch flights home. Voting on the motion to end debate on the spending bill began shortly after midnight.

“It’s a juvenile process we go through every time we deal with one of these,” said Corker, who is retiring.

But Majority Leader Mitch McConnell, R-Ky., who worked to get cooperation from Risch and Paul, said he wanted to finish the bill.

“I’ve been in continuous discussions with several of our members who were legitimately unhappy with one aspect or another,” McConnell said. “I must say after a long and intense day of successfull discussions, I’m relieved, rather than depressed we might be able to actually finish tonight.”

Paul was among many Republicans opposed to the spending increase.

"Every Republican would vote against this disgusting pork bill if a Democrat were president," Sen Ben Sasse, R-Neb., said in a statement. "This spending kegger is a wildly irresponsible use of the taxpayers' money, and the president should not sign it."

With the vote, the Senate will break Friday for a two-week recess. Lawmakers were eager to pass the bill before midnight, Friday, when a temporary spending bill expires.

The bill was introduced late Wednesday, and represents a bipartisan agreement to boost spending for the rest of the fiscal year. But while the rushed process and policy riders led to opposition from some Democrats and Republicans, big increases for domestic and military spending helped provide the votes needed to pass the bill.

“Overall, we Democrats are very happy with what we were able to accomplish on a number of priorities to the middle class and America, including infrastructure, education, opioids, mental health, and child care,” said Minority Leader Chuck Schumer, D-N.Y.

Republicans praised the increased military spending, after years of cuts have damaged readiness, lawmakers said.

“This legislation will provide the largest year-on-year increase in defense funding in fifteen years,” McConnell said. “After years of disproportionate cuts to our armed services, Congress has begun to provide adequate resources -- to put an end to the harmful decline in combat readiness.”

Al Weaver contributed