RICHMOND, Va. — Bob McDonnell, the former governor of Virginia who was convicted in September on corruption charges, was sentenced to 24 months in prison on Tuesday in one of the most spectacular falls of a statewide official in the history of the commonwealth.

Mr. McDonnell, 60, whose lawyers had argued for community service in lieu of prison time, was sentenced by Judge James R. Spencer of Federal District Court, who after a lengthy discourse on sentencing guidelines and the nature of guilt and remorse concluded that “a price must be paid.”

Judge Spencer said he found the situation heartbreaking and the crimes confounding. But “unlike Pontius Pilate,” he said, “I can’t wash my hands of it all.”

The sentence was more than Mr. McDonnell — whose name was once floated as a possible candidate for the White House — had hoped for. But it was far less than the 10 to 12 years recommended by the federal probation office and the six and a half years later sought by prosecutors. Mr. McDonnell will face two years of supervision upon release.