House Democratic Leader Nancy Pelosi of Calif., right, speaks as Senate Minority Leader Harry Reid of Nev., left, listens as she talks to reporters on Capitol Hill in Washington (AP Photo/Susan Walsh)

Legislation sparing the country the specter of a catastrophic national default or partial government shutdown is ready for President Barack Obama's signature after the Senate approved the measure by a comfortable margin.

The deal struck between Republican congressional leaders and Democrats, and passed earlier this week by the House, also sets the budget for the federal government for the next two years.

The Senate voted 64-35 for the measure in the early morning hours Friday, with Democrats and Republican defense hawks uniting to overcome opposition from GOP presidential candidates Rand Paul of Kentucky and Ted Cruz of Texas.

Obama had negotiated the accord with congressional leaders who were intent on steering the institution away from the brinkmanship and shutdown threats that have haunted it for years.

© 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.