A Manhattan judge on Monday offered nine months in prison to a teen accused of fatally beating a homeless man — after initially saying he’d let him off scot-free.

Branlee Gonzalez, 19, showed up in court expecting to score a sweetheart deal over last year’s slaying of Lucio Bravo, 69, but Supreme Court Justice Guy Mitchell unexpectedly stiffened the slap on the wrist when a Post reporter turned up to cover the proceeding.

According to authorities, surveillance video caught Gonzalez mercilessly pummeling Bravo and Juan Calderon, 39, along Sherman Avenue near Dyckman Street on May 18, 2017.

Calderon escaped with minor injuries, but Bravo lapsed into a coma and was placed on life support before dying five days later.

Court records show Mitchell in June told Gonzalez he likely get no time behind bars and a sealed record as a youthful offender if he pleaded guilty to first-degree manslaughter and stayed out of trouble.

The offer came in response to a defense portrayal of Gonzalez as a first-time offender who is the victim of a traumatic childhood — including sexual abuse by a family member — that “has followed him throughout his teenage years and has impaired his development.”

But Mitchell canceled that deal Monday. He told Gonzalez he could still get youthful-offender status but would also have to serve 1 ¹/₃ to four years in prison.

That sentence would see Gonzalez locked up for at least nine months, Mitchell said.

The judge, who was appointed to the Criminal Court bench by Mayor de Blasio in February 2015, didn’t explain his sudden change of heart.

The move came as a surprise to defense lawyer Luis Diaz, who pleaded with Mitchell to reduce his client’s potential punishment, saying Gonzalez “was headed to youthful offender and not going back to prison, and now the court has made an offer that requires the defendant to go to state prison.”

Prosecutor Sarah Marquez argued that Gonzalez — a reputed associate of the “Gorilla Stones” gang — deserved no less than 10 years behind bars, followed by five years’ probation.

In court papers filed last month, she wrote, “We know of no case in recent memory in which a defendant, indicted for Manslaughter in the First Degree for brutally beating a meant to death without justification, was granted a Youthful Offender adjudication without a significant state prison sentence.”

An autopsy ruled Bravo’s cause of death as “blunt force trauma to the head,” with “chronic alcoholism with hepatic cirrhosis” as a contributing cause.

In an April letter to the judge, Diaz conceded that Gonzalez had attacked Bravo, but noted that Bravo wasn’t treated immediately because he drunkenly “got up and walked away with the other victim” before suffering a fall that “could have been another cause for the trauma he suffered to his brain,”

Diaz blamed Gonzalez’s actions on the fact that he, too, had been drinking, and became enraged when Bravo and Calderon “began catcalling” Gonzalez’s female cousin, who authorities say is seen on the video dragging Gonzalez away from the victims.

Mitchell scheduled a Sept. 6 court hearing for Gonzalez, who’s free on $250,000 bond, to decide whether he’ll plead guilty or not.