Such oral dissents are rare, and they signal deep disagreements. But Chief Justice Roberts and Justice Breyer noted from the bench that the other side’s arguments were well presented.

Image Shaun McCutcheon, who brought the case with the Republican National Committee. Credit... Drew Angerer/Getty Images

Wednesday’s decision did not affect familiar base limits on contributions from individuals to candidates, currently $2,600 per candidate in primary and general elections. But it said that overall limits of $48,600 by individuals every two years for contributions to all federal candidates violated the First Amendment, as did separate aggregate limits on contributions to political party committees, currently $74,600.

In his written opinion, Justice Breyer said Wednesday’s decision would allow “a single individual to contribute millions of dollars to a political party or to a candidate’s campaign.” He was joined by Justices Ruth Bader Ginsburg, Sonia Sotomayor and Elena Kagan.

The ruling, which goes in effect in a matter of weeks, concerned only contributions from individuals. Federal law continues to ban direct contributions by corporations and unions, though they remain free to spend unlimited sums through “super PACs” and similar vehicles.

The case, McCutcheon v. Federal Election Commission, No. 12-536, was brought by Shaun McCutcheon, an Alabama businessman, and the Republican National Committee. Mr. McCutcheon, who had contributed a total of about $33,000 to 16 candidates for federal office in the 2012 election cycle, said he had wanted to give $1,776 each to 12 more but was stopped by the overall cap for individuals. The party committee said it wanted to receive contributions above the legal limit for political committees.

In an interview last fall, Mr. McCutcheon said his goal was to encourage the adoption of conservative principles. “To me,” he said, “being a conservative means smaller government and more freedom.”

Chief Justice Roberts said the core purpose of the First Amendment was to protect political speech from government interference, even if many people might welcome it.