A federal appeals court has thrown out the conviction of a former Goldman Sachs Group Inc computer programmer who had been convicted of stealing part of the Wall Street bank's high-frequency trading code.

The 2nd U.S. Circuit Court of Appeals overturned the conviction of Sergey Aleynikov on Thursday night and said an opinion explaining its reasoning would follow in due course.

It also directed the trial court to enter a judgment of acquittal. Generally this means a defendant cannot be retried.

The decision was swift, coming just hours after Aleynikov's lawyer argued in court to reverse the conviction. Aleynikov has been serving an eight-years prison sentence.

We are extremely gratified that the court of appeals refused to let this unjust conviction stand, the lawyer, Kevin Marino, said.

Ellen Davis, a spokeswoman for federal prosecutor Preet Bharara in Manhattan, declined to comment.

Goldman spokesman Michael DuVally also declined to comment.

The reversal is a setback for government efforts to crack down on thefts of intellectual property, including computer code.

Last month, federal authorities arrested Chinese computer programmer Bo Zhang, a resident of Queens, New York, on charges that he stole nearly $10 million of software code from the Federal Reserve Bank of New York.

Aleynikov, 42, was convicted by a federal jury in December 2010 of stealing trade secrets in violation of the Economic Espionage Act of 1996

Prosecutors accused Aleynikov of copying and removing trading code from Goldman in 2009, shortly before taking a new job at Teza Technologies LLC, a high-frequency trading start-up firm in Chicago. Teza was not accused of wrongdoing.

Aleynikov, who was once a competitive ballroom dancer, has three children and has held dual citizenship in the United States and Russia.

Marino argued that his client's conduct did not violate the espionage law, or a separate federal law barring the transportation of stolen property across state lines.

He argued in court papers that prosecutors expanded two federal criminal statutes beyond anything Congress could have imagined, and that Aleynikov was punished as severely as someone who stole $20 million.

Aleynikov has been serving his sentence at a federal prison in Fort Dix, New Jersey, according to the Federal Bureau of Prisons.

The case is U.S. v. Aleynikov, 2nd U.S. Circuit Court of Appeals, No. 11-1126. The lower court case was U.S. v. Aleynikov, U.S. District Court, Southern District of New York, No. 10-00096.

(Reporting By Grant McCool and Jonathan Stempel; Editing by Gerald E. McCormick and John Wallace)