WASHINGTON — Just before the Senate left town for its August break, a dozen or so undecided Democrats met in the Capitol with senior diplomats from Britain, China, France, Germany and Russia who delivered a blunt, joint message: Their nuclear agreement with Iran was the best they could expect. The five world powers had no intention of returning to the negotiating table.

“They basically said unanimously this is as good a deal as you could get and we are moving ahead with it,” recalled Senator Chris Coons, the Delaware Democrat who lent crucial support to the deal this week despite some reservations. “They were clear and strong that we will not join you in re-imposing sanctions.”

For many if not most Democrats, it was that message that ultimately solidified their decisions, leading to President Obama on Wednesday securing enough votes to put the agreement in place over fierce and united Republican opposition. One after another, lawmakers pointed to the warnings from foreign leaders that their own sanctions against Iran would be lifted regardless of what the United States did.

But the president’s potentially legacy-defining victory — a highly partisan one in the end — was also the result of an aggressive, cooperative strategy between the White House and congressional Democrats to forcefully push back against Republican critics, whose allies had begun a determined, $20 million-plus campaign to kill the deal.