WASHINGTON (AP) — 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 justices 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 Supreme Court sent the case back to lower courts to decide whether prosecutors have enough evidence 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 in return except help a constituent gain access to other public figures.

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

Chief Justice John Roberts agreed with McDonnell that the jury instruction of “official acts” at his trial was so broad it could include virtually any action a public official might take while in office, leaving politicians across the country subject to the whims of prosecutors.

“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 said.

McDonnell’s attorney Noel Francisco called the ruling a “home run.” He 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 Democrat and Republican – 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.

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.

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 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 on the opinion Monday.

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