The deal includes an abortion funding ban for Washington, D.C., which Obama has signed into law before. And, bipartisan sources added, the agreement calls for the Senate to hold votes on rescinding the health care law and eliminating funding for Planned Parenthood.
Republicans added that the agreement denies additional funding to the IRS, requires yearly audits of the Consumer Financial Protection Bureau and mandates additional study of the health care law that they believe will aid their fight to repeal it.
The deal appeared to come together very late in the day, as Republicans conferred in private and reviewed the proposed terms. Official announcements began going out before 11 p.m.
Obama called Reid Friday evening at 11:22 p.m. and Boehner at 11:25 p.m. to thank them for their hard work.
A government shutdown would have had wide effects, including perhaps 800,000 federal worker furloughs, curtailment of public services such as mortgage, passport and loan processing, delayed tax refunds, interruption of military paychecks and disruption to a recovering economy.
Abortion took center stage in the fight over spending cuts. The abortion measure in the House Republicans' extension bill, and one they say they won't budge on, would reinstate a policy that prevented the District of Columbia from using locally generated taxes to provide financial help to poor women for abortions.
The House voted earlier this year to defund Planned Parenthood, but 41 Democrats in the Senate said they would not support that legislation. The White House said the president would not agree to any ban on funds to Planned Parenthood.
"We've come to realize that the moving target has now focused a bull's eye on women in America," Reid said before the agreement Friday. "We agreed on a number. But we are not -- we are not -- bending on women's health."
Planned Parenthood already is prohibited from using any federal funds for abortion-related services. Officials of the organization said more than 90 percent of what Planned Parenthood clinics do has nothing to do with abortion, but rather focuses on women's health services such as pap smears and mammograms.
Abortion opponents say federal funding for other services means money freed up for the purposes of conducting abortions, which they regard as ending human life.
The last time the government shutdown fully was in 1995, under President Clinton, for five days. A 21-day partial shutdown followed soon after.
ABC News' John Parkinson, Matthew Jaffe and Huma Khan contributed to this report.