Before he was Bernard Kerik, world-famous NYPD commissioner, he was Bernie Kerik, world-class mooch.

Not only did Kerik, by his own admission, take $255,000 in free renovations on his Bronx apartment, but a buddy paid for the engagement ring Kerik gave his fiancée — and for Kerik’s wedding, too, the friend testified yesterday.

Best man Larry Ray told Bronx jurors that over the course of their five-year friendship, he lent Kerik more than $100,000, including money for Kerik’s 1998 wedding — money that was never returned.

“He couldn’t pay the bill at the end of the wedding, so I paid the bill,” Ray said, adding that Kerik “was greedy, and there was always an ulterior motive.”

Ray testified at the trial of Frank and Peter DiTommaso, accused of lying to the feds about Kerik’s renovations.