In a victory for President Barack Obama, the Senate passed bipartisan legislation Friday night to strengthen the administration's hand in global trade talks, clearing the way for a highly unpredictable summer showdown in the House.

The vote was 62-37 to give Obama authority to complete trade deals that Congress could approve or reject, but not change. A total of 48 Republicans supported the measure, but only 14 of the Senate's 44 Democrats backed a president of their own party on legislation near the top of his second-term agenda.

Obama hailed the vote in a statement that said trade deals "done right" are important to "expanding opportunities for the middle class, leveling the playing field for American workers and establishing rules for the global economy that help our businesses grow and hire."

Separate legislation to prevent parts of the anti-terror Patriot Act from lapsing on June 1 was stalled, held up by Kentucky Sen. Rand Paul, a presidential hopeful. "My filibuster continues to end NSA illegal spying," he tweeted, referring to a mass collection of telephone records by the National Security Agency.

A bill to prevent a cutoff in federal highway funding also awaited action by lawmakers who covetously eyed a weeklong vacation — set to begin whenever Paul relented and the work was done.

Senate passage of the trade bill capped two weeks of tense votes and near-death experiences for legislation the administration hopes will help complete an agreement with Japan and 10 other countries in the Pacific region.

Senate Majority Leader Mitch McConnell, R-Ky., who was Obama's indispensable ally in passing the bill, said it would create "new opportunities for bigger paychecks, better jobs and a stronger economy.

"The tools it contains will allow us to knock down unfair foreign trade barriers that discriminate against American workers and products stamped 'Made in the USA,'" he said.

A fierce fight is likely in the House.

Speaker John Boehner supports the measure, and said in a written statement that Republicans will do their part to pass it.

But in a challenge to Obama, the Ohio Republican added that "ultimately success will require Democrats putting politics aside and doing what's best for the country."

Dozens of majority Republicans currently oppose the legislation, either out of ideological reasons or because they are loath to enhance Obama's authority, especially at their own expense.

And Obama's fellow Democrats show little inclination to support legislation that much of organized labor opposes.

In the run-up to a final Senate vote, Democratic supporters of the legislation were at pains to lay to rest concerns that the legislation, like previous trade bills, could be blamed for a steady loss of jobs.

"The Senate now has the opportunity to throw the 1990s NAFTA playbook into the dust bin of history," said Sen. Ron Wyden, D-Ore. He referred to the North American Free Trade Agreement, passed two decades ago, and a symbol to this day, fairly or not, of the loss of unemployment to a country with lax worker safety laws and low wages.

Like Obama, Wyden and others said this law had far stronger protections built into it.

One final attempt to add another one failed narrowly, 51-48, a few hours before the bill cleared.

It came on a proposal, by Sens. Rob Portman, R-Ohio, who supported the trade bill, and Debbie Stabenow, D-Mich., who opposed it. They sought to made allegations of currency manipulation subject to the same "dispute settlement procedures" as other obligations under any trade deal.

Treasury Secretary Jacob Lew warned earlier that its approval could cause Obama to veto the legislation.

Portman, who was U.S. trade representative under former President George W. Bush, scoffed at the threat. "I don't think so," he said. "I think he (Obama) understands the importance" of his ability to conclude trade deals without congressional changes.

The bill also included $1.8 billion in retraining funds for American workers who lose their jobs as a result of exports. Sen. Jeff Flake, R-Ariz., said the program duplicated other federal efforts, but his attempt to strip out the funds was defeated, 53-35.

Allies on one bill, McConnell and the White House were on different sides on the Patriot Act legislation.

White House spokesman Josh Earnest prodded the Senate to accept a House-passed bill renewing anti-terrorism programs due to expire June 1, including a provision to eliminate the National Security Agency's ability to collect mass telephone records of Americans. Instead, the material would remain with phone companies, with government searches of the information allowed by court order on a case-by-case basis.

"The untried — and as of yet, nonexistent — bulk-collection system envisioned under that bill would be slower and more cumbersome than the one that currently helps keep us safe," McConnell said in remarks on the Senate floor. At worst, he added, "it might not work at all."

The highway bill was the least controversial of the three on the Senate's pre-vacation agenda, but only because lawmakers agreed in advance on a two-month extension of the current law. The House and Senate will need to return to the issue this summer.

Lawmakers whose time generally is scheduled far in advance adjusted as best they could as the Senate struggled with work put off until the last minute.

"It's not the weather, it's the Senate that's the problem," said Sen. Lamar Alexander, R-Tenn., hoping to make it home by Saturday night for a turn as pianist with the Memphis Symphony Orchestra.

___

Associated Press reporter Ken Dilanian contributed to this story.