The Supreme Court sided Thursday with a discredited investment adviser, finding that the Securities and Exchange Commission judge who penalized him was improperly appointed.

Raymond J. Lucia was fined $300,000 and barred for life from working as a financial adviser in 2012 after an SEC judge found his “Buckets of Money” seminars misled potential investors and violated anti-fraud statutes.

He argued that the administrative law judge lacked the authority to do his job, and the Supreme Court in a divided decision agreed.

The ruling “wiped off the books” the finding in Lucia’s case and provides a new hearing before a properly appointed agency judge, said Justice Elena Kagan in announcing the opinion she wrote for the majority.

It was not immediately clear how many other SEC rulings will require new hearings or how the decision will affect administrative law judges for other government departments.

In a separate opinion, Justice Stephen G. Breyer agreed in part with the outcome but called the reasoning “problematic” and warned of potential consequences for employees throughout government.

The court, he wrote, risks “unraveling, step-by-step, the foundations of the federal government’s administrative adjudication system as it has existed for decades, and perhaps of the merit-based civil-service system in general,” Breyer wrote.

The high court was reviewing whether agency judges are simply government employees with limited authority or, as Lucia argued, should be classified as officers of the United States.

The SEC’s judges, like the one in Lucia’s case, were appointed through an administrative process by agency staff. The Constitution’s Appointments Clause demands more for those serving as constitutional officers, requiring them to be appointed by either the president, the courts or heads of departments.

In its opinion Thursday, the court said administrative law judges are constitutional officers because they exercise “significant authority,” presiding at hearings, issuing opinions and deciding sanctions for those charged with violating the nation’s securities laws.

The administrative law judges have “all authority needed to ensure fair and orderly adversarial hearings — indeed nearly all the tools of federal trial judges,” Kagan wrote in her 13-page opinion.

In remarks from the bench, she added that the case matters because if an agency judge has been “doing his job without that authority, then someone can step up and argue that the things he’s done should be voided, wiped off of the books.”

In all, seven justices agreed with Lucia that the judge was improperly appointed. Justices Ruth Bader Ginsburg and Sonia Sotomayor dissented.

While administrative law judges wield “extensive powers,” Sotomayor wrote, “they lack final decision-making authority” because the commissioners can choose to review the rulings.

President Trump’s administration made the unusual decision to support Lucia instead of defending the government, and the court appointed a New York lawyer to argue for the SEC.

At oral argument in April, Lucia’s lawyer Mark Perry told the justices that about 150 judges could be affected by the court’s decision.

To try to stave off challenges to other SEC decisions, commissioners in November ratified “the agency’s prior appointment” of its five administrative law judges, which Deputy Solicitor General Jeffrey B. Wall has said satisfies the constitutional requirement and eliminates the problem.

Perry disagreed in court filings and said the commission’s “ratification” was not the formal appointment the Constitution requires.

Christopher Veatch, a former SEC enforcement attorney, said Thursday’s narrow ruling left unanswered whether the SEC’s order fixed the other pending cases and opens the door to additional litigation.

An SEC spokesman said the commission is reviewing the opinion.

The case reached the Supreme Court after a three-judge panel of the U.S. Court of Appeals for the D.C. Circuit rejected Lucia’s constitutional challenge. The full court, sitting en banc, was divided 5 to 5 after oral argument and did not issue a ruling.

The case is Lucia v. SEC.

Robert Barnes contributed to this report