MIAMI — A divided Florida appeals court on Wednesday threw out the murder conviction and lengthy prison sentence for a former FBI agent in the decades-old mob-style killing of a gambling executive.

The 3rd District Court of Appeal ruled 2-1 that former agent John Connolly was improperly convicted and sentenced to 40 years in prison for his role in the 1982 slaying of World Jai-Alai President John Callahan.

A hit man testified in the 2008 trial that he fatally shot Callahan after Connolly tipped Boston mobster James "Whitey" Bulger and his lieutenant, Stephen "The Riflman" Flemmi, that the executive would implicate them in another death. The appeals court initially upheld Connolly's conviction in 2011 without comment but overturned it after Connolly's lawyer asked for reconsideration.

In the court's new ruling, a panel of judges determined that Connolly's second-degree murder conviction was barred by the statute of limitations applicable at the time. His attorneys argued that prosecutors improperly used a firearms allegation to enhance the charge to one potentially punishable by life in prison — for which the statute of limitations would not apply.

"Connolly's conviction for second-degree murder with a firearm should not have been reclassified to a life felony in order to circumvent the statute of limitation," wrote Chief Judge Frank A. Shepherd and Judge Richard J. Suarez in the majority opinion. "Without the fundamentally erroneous reclassification, the first-degree felony of second-degree murder was time-barred."

Judge Leslie B. Rothenberg dissented.

Connolly has long denied a role in Callahan's slaying. Trial testimony showed he was 1,500 miles away in Massachusetts when Callahan was killed by Bulger's hit man John Martorano, who made a deal with prosecutors in return for his testimony in Connolly's case and others. The only evidence that Connolly might have had a firearm when Callahan was killed is the standard FBI practice that agents are armed while on duty.

The court said Connolly should be freed from prison based on the erroneous conviction, but it issued a stay so prosecutors could appeal further. A spokesman for Miami-Dade State Attorney Katherine Fernandez Rundle did not immediately return a call seeking comment Wednesday.

Bulger, 84, was a fugitive for 16 years before his 2011 capture at an apartment in Santa Monica, California. He was convicted in August 2013 of a host of crimes in a racketeering indictment, including playing a role in 11 murders while he led a violent gang. Bulger is serving a life sentence in federal prison but is appealing.

Connolly was convicted in 2002 of racketeering for his dealings with Bulger's gang, mainly protecting them from prosecution and tipping them about informants in their ranks. He was sentenced to 10 years in federal prison in that case. That sentence has been completed.