SACRAMENTO, Calif. (AP)  California Assembly members considered swing votes on legislation to reduce carbon emissions by charging polluters were among the top recipients of donations from oil companies, an analysis of campaign finance filings shows.

Records show oil companies in the Western States Petroleum Association and other industry groups donated more than $240,000 to Assembly members in the first half of 2017, as lawmakers hotly debated extending California”s cap and trade program.

The oil industry was involved in weeks of closed-door negotiations with Gov. Jerry Brown and lawmakers, winning concessions and eventually backing the deal as a favorable market-based approach to reducing pollution. Some environmental advocates, meanwhile, argued oil companies won too much.

Of the nine Assembly members who received more than $10,000 from oil interests, six are moderate Democrats or Republicans who were considered swing votes on the deal. All six backed the deal, and it squeaked through the lower chamber by a single vote. In total, oil interests gave to nearly half the chamber”s 80 members, with most receiving less than $5,000.

Assemblyman Rudy Salas, a Bakersfield Democrat often aligned with business interests, raked in $19,700 from the oil companies, more than any other lawmaker. Next was Assembly Republican Leader Chad Mayes, drawing $15,300 from oil interests. Mayes and six of his Republican colleagues backed the deal, a move that”s caused angst in the party. Spokesmen for Salas and Mayes did not immediately comment.

Most Republican lawmakers argue the deal will raise gas prices and hurt consumers. But the oil industry tends to prefer an approach that allows them to obtain and trade pollution permits. The deal hands out some free allowances and bars local air districts from adopting stricter regulations on refineries, two wins for the oil industry.

But Ann Notthoff of the National Resources Defense Council, which supported the bill, said the oil industry didn”t score an outright victory on cap and trade.

“The oil industry sees the writing on the wall,” she said. “Their interest was to make compliance as affordable as they could.”

Republicans Jordan Cunningham of Templeton and Marc Steinorth of Rancho Cucamonga received $14,300 and $11,900 from oil companies, respectively. Both backed the bill. Among Democrats, Raul Bocanegra of Los Angeles and Tim Grayson of Concord brought in $13,400 and $12,400 respectively. Both are considered moderate, business-aligned Democrats.

Grayson said he believes oil interests give him money because there are refineries in his district. He voted for the deal based on research and what he believed was in the best interest of his constituents, he said.

“We were hearing every single side and listening to the arguments and the stories that stemmed from every single perspective,” Grayson said. “Nobody got everything they wanted, but everyone got something.”

Bocanegra”s office declined to comment, while the rest did not immediately offer a response.

Three other Assembly lawmakers who are not typically swing votes also received more than $10,000 from oil interests. They are Democrat Blanca Rubio, who backed the deal, and Republicans Jay Obernolte and Vince Fong, who opposed it.

Chevron Corporation, the California Resources Corporation and Tesoro Corporation  now known as Andeavor  were the biggest oil-company contributors to Assembly campaigns. Spokespeople for all three, as well as Valero Energy, did not immediately comment.

Political campaign contributions from the California Independent Petroleum Association aren”t tied to lawmakers” stances on individual policies, said Sabrina Lockhart, a spokeswoman for the group. “In general, CIPA supports candidates who understand that a more vibrant energy sector will result in a stronger California economy,” she said.

.Spokesmen for Phillips 66 and BP deferred comment to the Western States Petroleum Association, which did not comment on its members” donations to political campaigns.

Jessica Levinson, a law professor at Loyola who is an expert in government ethics, said it”s typical to see money from wealthy interest groups going to potential swing votes on a bill like cap and trade.

“If someone”s a solid yes or no, the money isn”t going to flow there,” Levinson said. “But if someone is on the fence, that”s where you”re going to see the money.”

Donating to lawmakers wasn”t the industry”s only means of influence. Chevron has already spent $7 million this year lobbying on cap and trade and other bills, while the Western States Petroleum Association spent $4 million, Tesoro spent $2.5 million and Valero more than $1 million.

“In order to ensure the ability of California”s oil and gas producers to continue to provide essential fuels, jobs, technology and revenues for the state, it is necessary to engage robustly in the political process,” Western States Petroleum Association President Catherine Reheis-Boyd said in a statement.