The agreement was announced by the Senate Majority Leader, Harry Reid, on the Senate floor.
"The compromise we reached will provide our economy with the stability it desperately needs," he said.
The House of Representatives will vote on it soon.
"The eyes of the world have been on Washington all this week. That is a gross understatement. While they witnessed a great deal of political discord, today they will also see Congress reach a historic bipartisan agreement to reopen the government and avert a default on the nation's bills," he said.
More From This Section
"But in the end, political adversaries set aside their differences and disagreements to prevent that disaster," he said.
The new compromise agreement, he said, will fund the government through January 15, 2014 and averts default through February 7, during which time they can work toward a long-term budget agreement that prevents these frequent crises.
The Senate Minority Leader, Mitch McConnell, said the deal will reopen the government, avoid default and protect the historic cuts they achieved under the Budget Control Act.
"This legislation is the largest spending reduction bill of the last quarter-century and the largest deficit reduction bill since 1981 that didn't include a tax hike. Preserving this law is critically important to the future of our country," McConnell said.
With time running out, news reports said the legislation would first move through the House and then would breeze through the Senate so as to pass the legislation in time before the October 17 deadline to avoid an unprecedented default on the debt.