A Manhattan judge sentenced ​former Knicks guard Raymond​ ​Felton Wednesday to 500 hours of community service and a $5,000 fine​ ​for possessing an illegal gun that his ex-wife turned into cops, claiming he’d pointed it at her.

“I apologize. I realize what I did was wrong,”​ ​mumbled the recently ​​traded ​Felton, who now plays for the Dallas Mavericks. He pleaded guilty in court to attempted ​​criminal possession of a weapon and criminal possession of a firearm​ ​as part of a no-jail plea deal.

The troubled baller, who wore a wrinkled gray suit in court, has a​ ​year to complete the community service, ​which he can perform out of state, ​said Justice Larry Stevens.

Felton, 29, was busted in February after his ex-wife, Ariane Raymondo,​ ​turned him in to police for the illegal pistol and large capacity ​magazine.

She showed up at the 20th Police Precinct with the Belgian-made FNH​ ​Five-Seven 28mm handgun and told cops her hubby had waved it at her ​twice during heated spats at their Upper West Side pad.

The illegal gun’s magazine was packed with 18 body-armor-piercing​ ​bullets, according to law enforcement sources.

The gorgeous 24-year-old law student also told cops Felton was a​ ​serial cheater, carrying on more than one affair during their rocky​ ​19-month marriage.