An attorney who admitted leaking the confidential grand jury testimony of Barry Bonds and other athletes was sentenced Thursday to two and a half years in prison, by far the harshest penalty to result from the government's steroids investigation.

Troy Ellerman, 44, pleaded guilty in February to allowing a San Francisco Chronicle reporter to view transcripts of testimony by Bonds, Jason Giambi, Gary Sheffield and other athletes embroiled in the probe. He initially blamed federal investigators for leaking the testimony.

U.S. District Court Judge Jeffrey White approved Ellerman's latest deal with prosecutors about a month after rejecting a plea agreement calling for a prison term of 15-24 months. White harshly criticized that sentence as too lenient.

Ellerman's new deal called for up to two years, nine months in prison. White opted for a slightly shorter sentence but required Ellerman, who voluntarily gave up his license to practice law in California, to give 10 speeches on conduct to law students. He did not assess a fine.

"This affected, and infected every aspect of the judicial system," White said.

Ellerman was a successful Sacramento attorney when Victor Conte, founder of the Bay Area Laboratory Co-Operative, hired him following a raid of the Burlingame nutritional supplements lab by federal agents.

He also later served as the attorney for BALCO vice president James Valente. It was while he was representing Valente that he allowed reporter Mark Fainaru-Wada to view the players' grand jury testimony, according to the plea agreement.

Fainaru-Wada and reporter Lance Williams published stories in 2004 reporting Giambi and others had admitted using steroids, while Bonds and Sheffield testified they didn't knowingly take the drugs. The leaked testimony was featured prominently in the writers' book "Game of Shadows," which recounts the alleged steroid use of Bonds, who is five home runs away from breaking Hank Aaron's all-time home run record.

A friend and former private investigator in Ellerman's law firm turned him in to authorities after they had a falling out.

Ellerman pleaded guilty to four felony counts of obstruction of justice and related charges, and federal prosecutors dropped their case against the two reporters. They had faced up to 18 months in prison for refusing to divulge the source of the leak.

Valente and Conte pleaded guilty to steroids-related charges in an earlier phase of the BALCO investigation, along with chemist Patrick Arnold, Bonds' personal trainer Greg Anderson and track coach Remi Korchemny.

Korchemny and Valente were sentenced to probation, and the others were each sentenced to jail terms no longer than four months. Anderson remains in prison, where he returned after refusing to testify before a grand jury investigating possible perjury and tax evasion charges against Bonds.

The case is United States v. Ellerman, 07-0080.