WASHINGTON — A unanimous Supreme Court on Monday overturned the bribery conviction of former Virginia Gov. Bob McDonnell in a ruling that could make it harder for prosecutors to bring corruption cases against elected officials.

McDonnell had been found guilty in 2014 of accepting more than $165,000 in gifts and loans from a wealthy businessman in exchange for promoting a dietary supplement. He was sentenced to two years in prison, but was allowed to remain free while the justices weighed his appeal.

The court voted to narrow the scope of a law that bars public officials from taking gifts in exchange for “official action,” saying it does not cover routine courtesies like setting up meetings or hosting events for constituents.

The case was sent back to lower courts to decide whether prosecutors have enough evidence to try McDonnell again.

McDonnell said he never took any official action to benefit Star Scientific Inc. CEO Jonnie Williams or pressured other state officials to do so. McDonnell claims he did nothing except to help a constituent gain access to other public figures.

Prosecutors insisted that McDonnell accepted personal benefits with the understanding that he would try to take official action to help Williams.

Chief Justice John Roberts agreed with McDonnell that the instructions to his trial jury about what constitutes “official acts” was so broad that it could include virtually any action a public official might take while in office. That could leave politicians across the country subject to the whims of prosecutors, he said.

“Setting up a meeting, talking to another official, or organizing an event (or agreeing to do so) — without more —does not fit that definition of official act,” Roberts wrote.

“There is no doubt that this case is distasteful; it may be worse than that,” he wrote. “But our concern is not with tawdry tales of Ferraris, Rolexes and ball gowns,” a reference to some of the expensive gifts McDonnell received. “It is instead with the broader legal implications of the government’s boundless interpretation of the federal bribery statute.”

In a statement, McDonnell thanked the justices and said he has not and would not “betray the sacred trust” of the Virginia people. He said he hoped the matter will soon be over so that he and his family can begin to rebuild their lives.

McDonnell’s attorney Noel Francisco called the decision a “home run” and said the strength of the court’s ruling makes it unlikely that a new trial would go forward.

McDonnell’s wife, Maureen, also was convicted of corruption and was sentenced to one year and one day in prison. Her appeal has been on hold while the Supreme Court considered her husband’s case.

Maureen McDonnell’s attorney, William Burck, said Monday’s ruling “requires that her conviction immediately be tossed out as well.”

In his opinion, Roberts noted that McDonnell had won the support of several influential former White House attorneys — both Democrats and Republicans — as well as dozens of state attorneys general. Those officials told the court that upholding McDonnell’s conviction would cripple the ability of elected officials to do their jobs.

The ruling could have sweeping implications for the governors, senators and other elected officials who either are under indictment or have been convicted. There have already been some signs of its potential impact: in New York, a federal judge said last month that former Assembly Speaker Sheldon Silver, convicted of illegally pocketing $5 million, could wait until after the Supreme Court ruling to report to prison.

The U.S. Attorney’s in New York issued a statement Monday saying the actions that led to Silver’s conviction fall within the court’s latest ruling.

Tara Malloy, deputy executive director of the watchdog group Campaign Legal Center, said the ruling “makes it even more difficult to protect our democracy from attempts by officeholders to peddle political access and influence to the highest bidder.”

There is no dispute that McDonnell received multiple payments and gifts from Williams, which was not illegal at the time under Virginia ethics laws.

The gifts included nearly $20,000 in designer clothing and accessories for McDonnell’s wife, a $6,500 engraved Rolex watch, $15,000 in catering for their daughter’s wedding, and free family vacations and golf trips for their boys. Williams also provided three loans totaling $120,000.

As the gifts came in, McDonnell helped set up meetings with state health officials, appeared at promotional events and even hosted a launch luncheon for the dietary supplement at the governor’s mansion. Williams was seeking state money and the credibility of Virginia’s universities to perform clinical research that would support his company’s drug.

A federal appeals court unanimously had upheld the former governor’s convictions last year.

McDonnell insists that he never put any pressure on state officials and that Williams ultimately never got the official action he wanted — state funding for medical studies on the dietary pills. The former governor argued the Justice Department was unfairly criminalizing “everyday acts” that are a typical part of the job.

Roberts agreed that the government’s position “could cast a pall of potential prosecution” over public officials interacting with the people they serve.

“The basic compact underlying representative government assumes that public officials will hear from their constituents and act appropriately on their concerns,” Roberts said.

The Justice Department declined to comment Monday on the opinion.

Some experts said the ruling may not be a major obstacle to future corruption prosecutions.

“I don’t think there are many public corruption prosecutions based on just a meeting,” said Jeffrey Bellin, a professor at William & Mary Law School. “In the typical federal corruption case, the government is always alleging that there is more going on than just a meeting.”

Associated Press Writers Eric Tucker and Alanna Durkin Richer in Richmond, Virginia, contributed to this report.

SUBSCRIBE: Get the analysis of Mark Shields and David Brooks delivered to your inbox every week.