A former high-level official at the Environmental Protection Agency, who pretended to work for the CIA to avoid the office, said he was motivated by a sense of excitement and the rush of getting away with something.

John C. Beale, a former EPA senior policy advisor, explained his motivations for the first time in a federal courtroom Wednesday before he was sentenced to more than 2 ½ years in prison for stealing nearly $900,000 in taxpayer funds.

U.S. District Judge Ellen S. Huvelle said Beale’s deception had “made a mockery of working for the federal government.”

Beale, 65, admitted in September that he had skipped out on work for years by telling a series of supervisors, including top officials in EPA’s Office of Air and Radiation, that he was doing top-secret work for the CIA. He was paid for a total of 2 ½ years of work he did not perform since early 2000 and received about $500,000 in bonuses he did not deserve, according to his plea agreement.

Assistant U.S. Attorney James E. Smith said Beale ripped off the government in “notorious, historic fashion” and had become the poster child for problems with the federal government workforce.

He lied about contracting malaria to obtain a reserved parking space that cost the EPA $8,000 over three years. He took trips to visit his family in Los Angeles for which he charged the government more than $57,000.

“His actions are a stain on the work of tens of thousands of honest federal workers,” said Smith.

Standing at the courtroom lectern in a gray pin-striped suit, a remorseful Beale said he had “abused and betrayed” the trust he earned during his long career at EPA “by exploiting flaws in the management system” at the agency.

Beale’s case has attracted political attention, in part because his scheme went on during a period in which he worked for EPA administrator Gina McCarthy, while she led the Air and Radiation office. McCarthy started that job in 2009 and told investigators she began to suspect Beale in March 2012, according to the agency’s inspector general’s office.

In the courtroom Wednesday, Huvelle pressed Beale about what he did during his long absences from the office, saying, “That’s a lot of time. You could have just retired.”

Beale wasn’t golfing or taking expensive vacations, he said, but exercising, working on his houses and pursuing a research project he had started years earlier.

“In hindsight, I think, how stupid could a person be?” Beale said. “Shame has become my constant companion this past year.”

As part of Beale’s plea deal, he has agreed to repay the government nearly $900,000 in salary and bonuses, in addition to forfeiting more than $500,000.

Get updates on your area delivered via e-mail