San Francisco (CNN) -- Baseball legend Barry Bonds was sentenced Friday to two years of probation and 30 days of house arrest for obstruction of justice in a grand jury inquiry into illegal steroid use by professional athletes.
The sentence for Bonds, 47, came in a San Francisco federal courtroom less than two miles from the ballpark where he broke Hank Aaron's major league home run record in August 2007.
The "jury got it right. Mr. Bonds managed to obstruct justice," U.S. District Judge Susan Illston said during the sentencing.
Bonds bore a pleasant expression on his face upon hearing the sentence, which was immediately stayed pending an appeal.
He could have faced 15 months in prison, according to a sentencing memo filed in court this month.
The obstruction of justice conviction stemmed from his testimony to a grand jury looking into illegal steroid use by professional ballplayers.
Defense lawyers argued in the memo that the judge should accept the probation office's recommendation that Bonds be sentenced to two years of probation, fined $4,000 and ordered to perform 250 hours of community service.
The judge issued the fine, though a federal prosecutor earlier told the court that such a fine is almost laughable. That fine was also stayed pending appeal.
Prosecutors argued in court Friday that Bonds led a double life and noted that he had mistresses during his marriage.
In convicting Bonds in April, jurors said he was "evasive" in his testimony to the federal grand jury investigating steroid use.
"Because Bonds's efforts were a corrupt, intentional effort to interfere with that mission, a sentence of 15 months imprisonment is appropriate," the prosecution said in its memo to Judge Illston.
But jurors, who were deadlocked on three perjury counts, said it was not proved that Bonds lied when he testified that he had not knowingly used steroids. Prosecutors decided not to pursue a retrial.
Prosecutors still argued in the sentencing memo that Bonds' denials that he was "taking steroids and human growth hormone were patently false."
Bonds' testimony in December 2003 was part of the investigation that targeted his personal trainer, Greg Anderson, and employees of the California drug testing laboratory known as the Bay Area Laboratory Co-operative, or BALCO.
The testimony that led to Bonds' conviction came when a grand jury prosecutor asked Bonds whether Anderson ever gave him "anything that required a syringe to inject yourself with."
Bonds told the grand jury that only his personal doctors "ever touch me," and he then veered off the subject to say he never talked baseball with Anderson.
Defense lawyers argued that Bonds thought the creams and ointments Anderson was giving him were made of flaxseed oil.
Sentences for other athletes convicted in connection with the BALCO investigation have not included prison time.
CNN's Augie Martin, Dan Simon and Michael Martinez contributed to this report.