WHITE PLAINS — Bernard B. Kerik, a former New York police commissioner who rose to national prominence, was sentenced to four years in prison on Thursday after pleading guilty to eight felony charges, including tax fraud and lying to White House officials.

Under the terms of a plea agreement reached in November on the eve of his trial, the prosecution and the defense recommended that Judge Stephen C. Robinson sentence Mr. Kerik to 27 to 33 months in prison. But the judge departed from the sentencing recommendations, giving Mr. Kerik a longer sentence.

Prosecutors had called for Judge Robinson to make an example out of Mr. Kerik, and to punish him for his “egotism and hubris.”

“I think it’s fair to say that with great power comes great responsibility and great consequences,” Judge Robinson said. “I think the damage caused by Mr. Kerik is in some ways immeasurable.”

“The defendant’s egotism and hubris were the tragic flaws that led him to commit the considerable number of crimes to which he ultimately pleaded guilty,” the memo said. Mr. Kerik “became a wealthy man by shamelessly exploiting the most horrific civilian tragedy in this nation’s history.”