Senator Chris Coons, a Delaware Democrat, was just as effusive: “We can make a lasting difference in how the Senate of the United States works,” he said before snapping a picture of the group on his iPhone. “We can get it back to working.”

The group’s maneuvering offered members of both parties an escape hatch from a bitter dispute that Republicans and Democrats said could have easily stretched on days longer.

The coalition, which was first formed amid an earlier government shutdown, in the fall of 2013, began to stir to life on Friday afternoon, as it became clear the Senate would be unable to stave off a shutdown. Ms. Collins approached Senator Joe Manchin III, the West Virginia Democrat and the coalition’s co-chairman, on the Senate floor, and within hours a group of 17 senators were crowded into her office to sketch out terms of engagement.

The group eventually came to include a broad swath of institutionally minded senators, including the Republicans Jeff Flake of Arizona, Johnny Isakson of Georgia and Mike Rounds of South Dakota, and the Democrats Amy Klobuchar of Minnesota, Tim Kaine of Virginia and Doug Jones of Alabama.

Members of the group spent the weekend shuttling between Ms. Collins’s overcrowded office, where they snacked on Girl Scout cookies and popcorn, and the office suites of Mr. McConnell and Senator Chuck Schumer, the party leaders. As the weekend wore on, the group kept growing, up to 25 by Monday — crowded enough that one senator had to sit on a credenza.

They cycled through a series of ideas: Further shortening the length of the short-term spending bill; attaching a bill to protect Dreamers to another piece of must-pass legislation; demanding that Mr. McConnell put an immigration bill authored by Mr. Graham and Senator Richard J. Durbin, Democrat of Illinois, on the floor for a vote. Each was eventually deemed untenable.