WASHINGTON — Senate leaders struck a far-reaching bipartisan agreement on Wednesday that would add hundreds of billions of dollars to military and domestic programs over the next two years while raising the federal debt limit, moving to end the cycle of fiscal showdowns that have roiled the Capitol.

The accord between Senators Mitch McConnell of Kentucky, the majority leader, and Chuck Schumer of New York, his Democratic counterpart, would raise strict caps on military and domestic spending that were imposed in 2011 as part of a deal with President Barack Obama that was once seen as a key triumph for Republicans in Congress.

The deal would raise the spending caps by about $300 billion over two years. The limit on military spending would be increased by $80 billion in the current fiscal year and $85 billion in the next year, which begins Oct. 1. The limit on nondefense spending would increase by $63 billion this year and $68 billion next year.

But the accord was not without dramatics, and its passage in the House is not a foregone conclusion. As proof of that, Representative Nancy Pelosi of California, the House Democratic leader, took the House floor on Wednesday morning in opposition, protesting that the deal did nothing to bring lawmakers closer to protecting young immigrants brought to the country illegally as children. She then delivered a record-breaking speech that tied up the House for the entire day and into the night.