RIO DE JANEIRO—Brazil’s Supreme Court declared corporate donations to political parties and campaigns to be unconstitutional, in a ruling that could transform electoral politics in Latin America’s largest country.

Justices voted 8-3 late on Thursday in favor of a challenge, brought by Brazil’s national bar association, to electoral laws that allow companies to donate up to 2% of their previous year’s gross revenue to candidates or party campaign funds. Politicians running for office in the future will be able to receive money only from a pool of public electoral funds and from individuals, who may contribute up to 10% of their previous year’s earnings.

The decision was widely seen as the latest ripple effect of the corruption scandal surrounding state-run oil firm Petróleo Brasileiro SA, high-level politicians and a web of contractors that includes some of Brazil’s largest political donors. The so-called Car Wash investigation has unearthed a scheme under which construction firms overcharged Petrobras for contracts and then paid kickbacks to politicians and parties, highlighting the cozy ties between government and big companies in a nation long known for cronyism.

Brazil’s constitution doesn’t explicitly forbid donations by companies. But its first article, referenced by at least one justice who voted with the majority, says “all power emanates from the people, who exercise it through elected representatives or directly.”

“From now on, the mandates of politicians will actually belong to their voters, and companies will be able to fully dedicate themselves to that which they know how to do best: create jobs for the population,” said Marcus Vinicius Furtado Coêlho, president of the bar association.