The convictions of former state probation commissioner John O'Brien and two former deputies were overturned Monday by an appeals court, which said prosecutors failed to prove a scheme to favor politically connected job candidates was a federal crime.

O'Brien, Elizabeth Tavares and William Burke were found guilty in 2014 of charges including racketeering and mail fraud after a politically charged trial in U.S. District Court. They were accused of creating a sham system to make it appear candidates were being hired for jobs in the probation department on merit when in fact they were getting jobs because they had been sponsored by powerful state lawmakers.

"Although the actions of the defendants may well be judged distasteful, and even contrary to Massachusetts's personnel laws, the function of this Court is limited to determining whether they violated the federal criminal statutes," wrote Judge Juan Torruella, of the 1st U.S. Circuit Court of Appeals in ordering a judgment of acquittal.

He wrote that the judges found the government "overstepped its bounds in using federal criminal statutes to police the hiring practices" of state officials and "did not provide sufficient evidence to establish a criminal violation" of state law under its theory of the case.

O'Brien was sentenced to 18 months in prison, but the sentence had been stayed pending appeal, as was the three-month sentence handed to Tavares. Burke did not get prison time but also appealed his conviction.

No legislators were charged in the case, but several were named during trial testimony, including Robert DeLeo, the powerful Democratic speaker of the state House.

Prosecutors asserted at trial that DeLeo had been involved in a scheme to trade jobs at a newly created electronic monitoring facility in exchange for support from other lawmakers during his bid for the top post in the House. DeLeo strongly denied any wrongdoing.

"These false and scurrilous allegations can now be given an appropriate burial," DeLeo said in a statement following the appeals court ruling.

Defense attorneys for O'Brien, Tavares and Burke argued that no laws were broken and that O'Brien never knowingly gave a job to an unqualified applicant. The defense also argued that hiring people with political connections was not a practice limited to the probation department and was in fact rife throughout the state's judicial system.

U.S. Attorney Carmen Ortiz said at the time of the sentencing for the three defendants that the case had "exposed a pervasively dysfunctional system," allowing probation officers to be hired not for their qualifications but their political connections.

"We are disappointed with the court's decision and will continue to fulfill our responsibility to protect the public from corrupt officials by vigorously investigating and prosecuting public corruption in appropriate cases," Christina Sterling, a spokeswoman for Ortiz, said Monday night.