Barry Bonds' trainer, Greg Anderson, was ordered released from prison Thursday by a federal judge after being held in contempt for refusing to testify to a grand jury.

Anderson, who was at the center of the BALCO steroids case, spent most

of the past year in a federal detention center for refusing to

testify before a grand jury.

His release comes on the same day as the federal government's indictment of the ex-Giants slugger on four counts of perjury and one count of

obstruction of justice. He was cited for lying when he said he

didn't knowingly take steroids given to him by Anderson, his personal trainer

and longtime friend. Bonds also was charged with

lying that Anderson never injected him with steroids.

"Greg wouldn't do that," Bonds testified in December 2003 when

asked if Anderson ever gave him any drugs that needed to be

injected. 'He knows I'm against that stuff.' "

Geragos said Anderson didn't

cooperate with the grand jury that indicted Bonds.

"This indictment came out of left field,'' Geragos said on Thursday.

"Frankly I'm aghast. It looks like the government misled me and

Greg as well, saying this case couldn't go forward without him.''

Anderson did not comment as he left a federal prison east of San

Francisco.

Prosecutors promised Bonds they wouldn't charge him with any

drug-related counts if he testified truthfully. But according to

the indictment, Bonds repeatedly denied taking any steroids or

performance-enhancing drugs despite evidence to the contrary.

For instance, investigators seized a so-called "doping

calendar'' labeled "BB'' during a raid of Anderson's house.

"He could know other BBs,'' Bonds replied when shown the

calendar during his testimony.

Bonds said at the end of the 2003 season, Anderson rubbed some

cream on his arm that the trainer said would help him recover.

Anderson also gave him something he called "flax seed oil,'' Bonds

said.

Bonds then testified that prior to the 2003 season, he never

took anything supplied by Anderson -- which the indictment alleges

was a lie because the doping calendars seized from Anderson's house

were dated 2001.

Anderson was held in contempt of court and ordered to prison in 2006, a year after serving three months in prison after pleading guilty for his role in the BALCO scandal.

Anderson was initially ordered in March 2006 to testify to the grand jury investigating whether Bonds perjured himself when he testified to the original BALCO grand jury in December 2003 that he never knowingly used steroids or other banned performance enhancing drugs.

In August, Anderson's close friend and lawyer Paula Canny said that to pass the time in prison, Anderson cut his hair into a Mohawk with dreadlocks. Canny said Anderson's access

to television was limited, but he got updates on Bonds' all-time home run record pursuit by watching "SportsCenter" on ESPN.

Canny said at the time that Anderson said he would never testify and was determined to remain behind bars until the grand jury's term expires.

Information from The Associated Press was used in this report.