A teen who fatally beat a homeless man pleaded guilty Thursday as part of a sweetheart deal that will land him in jail for just nine months.

Branlee Gonzalez, 19, smirked his way through the proceeding in Manhattan Supreme Court then turned to his family in the gallery flashing a broad smile and gave them a thumbs up and wink before he was taken into custody.

Gonzalez had to cop to manslaughter and attempted assault but will have a sealed record as a youthful offender for the beatdown of Lucio Bravo, 69, on May 18, 2017.

Justice Guy Mitchell came under fire for initially telling Gonzalez he’d likely get a no-jail deal but changed his mind and offered one and a third to four years the same day The Post began covering the case.

That sentence will amount to Gonzalez serving about nine months for relentlessly pummeling Bravo and Juan Calderon, 39, along Sherman Avenue near Dyckman Street. Calderon suffered minor injuries.

Prosecutor Sarah Marquez had asked the judge for no less than 10 years, arguing that Gonzalez was an alleged “Gorilla Stones” gang member.

The victim’s grieving daughter also urged the judge to impose significant jail in a July 19 letter. “Please, I ask that the defendant pay for what he has done,” she wrote.

“Yes, I believe in second chances but I also believe the defendant must learn that all actions have consequences.”

She continued, “I also hope it is known that my father not only had a family but he was also a son, a father, a grandfather.”

Bravo, she acknowledged, suffered from alcoholism but added, “He was loved by everyone.”

“It is so painful to see that my daughters no longer have a grandfather,” she wrote.

Gonzalez, then 18, flew into a rage after Bravo allegedly catcalled his cousin. After the attack, Bravo slipped into a coma and died five days later at the hospital.

Defense lawyer Luis Diaz, who had argued in court papers that Gonzalez had endured a difficult childhood and deserved leniency, declined to comment after the plea.