When Senate Democrats gave Republicans the votes they needed to pass a contested banking bill, much of the attention went to Democrats facing tough reelection campaigns in states President Trump won handily in 2016.

The bill, which rolled back banking regulations put in place after the 2008 financial crisis, got a critical boost from several Democrats in Trump states, including Sens. Heidi Heitkamp (N.D.), Jon Tester (Mont.) and Joe Manchin III (W.Va.).

But when the Senate passed the measure last week, it cleared by a 67-to-31 vote. And a look at the roll reveals the political map alone did not determine which Democrats backed the bill. In three states Trump won — Ohio, Pennsylvania and Wisconsin — Democratic senators voted against the bill. Meanwhile, several of the senators who supported the bill hail from states that Democratic presidential nominee Hillary Clinton won, including Colorado and Virginia.

“I was surprised so many Democrats from blue states ended up voting for this,” said Jim Manley, who served as an aide for then-Senate Minority Leader Harry M. Reid (D-Nev.). “Democrats in states won big by Trump carried the bill initially, but a lot of blue-state Democrats helped get it over the finish line.”

The bill got support from Sen. Tim Kaine (D-Va.), Clinton's 2016 running mate. And another Virginian, Sen. Mark R. Warner (D), was one of the lead sponsors of the 2010 Dodd-Frank Wall Street Reform and Consumer Protection Act.

Sen. Sherrod Brown (Ohio)  — the ranking Democrat on the Senate banking panel — was one of the lead opponents of the measure, despite facing reelection in a state where Trump bested Clinton by several percentage points.

Other votes seemingly reflect state-specific concerns. Sens. Christopher A. Coons and Thomas R. Carper, both Democrats from reliably blue Delaware, typically vote with the bulk of their party, but they voted in favor of the measure. Their votes were widely expected, however, given that the financial sector backs the bill and has a large presence in Delaware.

Of the 17 Senate Democrats who voted for the measure, only six represent states that Trump won by more than two points.

The banking bill offers a wide range of regulator relief throughout the banking sector, and it specifically eases a range of regulations for banks with $50 billion to $250 billion in annual assets, eliminating some federal oversight for them and scaling back others.

In order for the legislation to reach Trump's desk, Congress still must reconcile the House and Senate versions. Rep. Jeb Hensarling (R-Tex.), chairman of the House Financial Services Committee, said this week that he wants the Senate version to look more like the House's, potentially threatening the legislation.

But why did so many blue- and purple-state Democrats join the push? Defenders of the bill said they were persuaded by its merits, arguing that it was motivated by the desire to free up capital for small regional and community banks in their states to curb the excesses of the Dodd-Frank bill that President Barack Obama signed in 2010 after the financial crash.

“What moved this bill was the longtime belief that there had been reduced access to capital, particularly in rural communities, and every state’s got some of that,” Warner said.

The legislation was also supported by both Democratic senators representing Michigan, a swing state that Obama won twice but that Trump took in a huge upset.

Sen. Gary Peters (D-Mich.) said that he frequently met with representatives of the credit unions and that their push for the bill helped win his support.

“Those are critical institutions, particularly in our more rural areas,” Peters said.

Opponents pointed to financial contributions from industry members. Over the past six years, the average supporter of the bill received $277,000 in campaign contributions from banks, credit unions and similar industries, more than double the average amount received by opponents of the bill, according to an analysis by MapLight, a nonprofit organization that studies the effect of money in politics.

An aggressive lobbying push may have also helped put the bill over the top. The Financial Services Roundtable, a D.C.-based lobbying firm that represents many of the United States' largest banks, devoted a team to pushing the bill and hired outside consultants for the effort. The week of Feb. 28, representatives of the nation's community banks brought thousands of people to Washington to “take every opportunity we could find” to meet with lawmakers and their staffs, said Ryan Donovan, a spokesman for the Credit Union National Association.

“There was a lot of one-on-one outreach throughout the year — regular phone calls, regular check-ins to see where the pressure points were, to see where folks might need counsel about the legislation,” said Anthony Cimino, a vice president of the Financial Services Roundtable, noting that the group's focus was mostly on moderate Senate Democrats.

More than 30 banks said at the end of 2017 that they had lobbied over the bill, including JPMorgan, Goldman Sachs and the Bank of Mellon New York, according to public records.

“Lobbying takes place because it gets results. That’s the reality,” said Sen. Robert Menendez (D-N.J.), who voted against the bill. “If you don't hear enough from consumers, and you hear only a chorus of voices on one time, that may affect your judgment.”

Sen. Jack Reed (D-R.I.), who voted against the bill, noted that representatives of regional banks — some of the bill's biggest beneficiaries — have a disproportionate presence on Capitol Hill.

“They come in a lot. Every year, we get representatives [from] the banking industry come in, and they’re local people, and they’re making an argument based on the ground in their state,” Reed said. “They have a presence and you have to recognize that.”