WASHINGTON - US Congressional leaders and the Bush administration have reached an agreement to set up a $700-billion government fund that will buy bad debt from ailing banks in a bid in an extraordinary intervention to prevent widespread economic collapse. Officials said that Congressional staff members would work through the night to finalize the language of the agreement and draft a bill, and that the bill would be brought to the House floor for a vote on Monday. After marathon talks into the wee hours of Sunday morning, leading lawmakers from both political parties came up with an agreement that altered key parts of the largest bailout plan in US history. "We've made great progress ... We have to get it committed to paper, so that we can formally agree," House of Representatives Speaker Nancy Pelosi told reporters after the talks. "We've still got more to do to finalize it, but I think we're there," said Treasury Secretary Henry Paulson, who participated in the protracted meetings the past two days. Senate Majority Leader Harry Reid described the agreement as a "breakthrough," which he attributed to a last-minute intervention by Pelosi. "We worked out everything," Sen. Judd Gregg said. The chief Republican negotiator on the issue, however, said he would still look at the final wording of the agreement and consult with colleagues before giving his final approval. Congressional leaders hope to have the House vote on the measure on Monday. A Senate vote would come later, barring any last-minute hitches. The preceding week of negotiations over the rescue package has roiled financial markets and altered the course of the US presidential campaign less than six weeks before the election. The centerpiece of the rescue effort calls for the US Treasury to buy $700 billion in troubled assets from banks and other investors as a way to free their balance sheets of bad debts. The money should help troubled lenders make new loans and restore a healthy flow of credit through the economy. The government would later try to sell the distressed assets"potentially worth much more that what the government will pay for them"at a profit hopefully. Congress is racing to reach an agreement before Asian financial markets open on Monday to avoid a repeat of last week's white-knuckle volatility.