WASHINGTON — The Senate approved a crucial bipartisan budget agreement early Friday that would avert a government default and end nearly five years of pitched battles between congressional Republicans and the Obama administration over fiscal policy.

The measure, which passed 64 to 35, now goes to the White House, where President Obama has said he will sign it.

“This agreement is a reminder that Washington can still choose to help, rather than hinder, America’s progress,” Mr. Obama said in a statement.

The Senate vote, held in the dead of night, was perhaps a fitting cap to the clashes between Republicans and the White House, which many warned had put the United States on the edge of economic calamity and which, in 2013, forced a 16-day shutdown of the federal government.