A judge sentenced rapper Meek Mill to two to four years in prison for a probation violation Monday, drawing outcry from fellow entertainers and the hip-hop world.

“The sentence handed down by the Judge — against the recommendation of the Assistant District Attorney and Probation Officer — is unjust and heavy handed,” Jay-Z wrote Monday on Facebook. “We will always stand by and support Meek Mill, both as he attempts to right this wrongful sentence and then in returning to his musical career.”

Jay-Z, whose Roc Nation manages Mill, has been a vocal supporter of criminal justice reform. He produced the docu-series “Time: The Kalief Browder Story” and collaborated with the New York Times for a video op-ed about the war on drugs.

Mill’s probation violations stem from a 2008 drug and gun conviction, for which he served eight months. The Philadelphia rapper, born Robert Williams, has since been in and out of Common Pleas Court Judge Genece E. Brinkley’s court for violating probation rules.

He was arrested twice in 2017, including for a March fight in a St. Louis airport (the charges were later dropped in exchange for community service). The rapper was also charged with reckless driving after video of him doing dirt-bike stunts on Manhattan streets was posted online.

The city prosecutor didn’t recommend imprisonment, saying Mill has been clean from drugs since January and has shown personal growth since the original crime, the Associated Press reported.

Brinkley responded by saying that the prosecutor was too new to the case and that Mill just “does what he wants.”

“I gave you break after break, and you basically just thumbed your nose at this court,” Brinkley told Mill, the Philadelphia Inquirer reported.

“I’m human. I’m not perfect,” Mill told Brinkley, according to the Inquirer. “I’m asking for mercy. You gave me the ladder to do what I have to do to prevail in my struggle. I made it this far, I can’t really go back and start over.” Mill sought treatment this year for a Percocet addiction.

Brinkley also cited him for scheduling concerts outside of Montgomery County, Pa., after her Aug. 17 ruling barred such travel, according to the Inquirer, and a failed drug test, AP reported.

Mill was put on house arrest for 90 days last year for a probation violation. He served five months in 2013 and saw his probation extended for another decade after failing to report to his probation officer and getting approval for travel.

After the judge’s ruling, Mill was taken into custody.

Monday’s sentence came as a surprise; it was the first such hearing before Brinkley at which neither Mill’s probation officer nor the city prosecutor recommended jail time, according to the Inquirer. When asked by reporters whether he’d appeal the sentence, defense attorney Brian J. McMonagle said, “You’re goddamned right I am.”

Under the sentence, Mill wouldn’t be eligible for parole for at least two years. Sending him to jail, he reportedly said during the hearing, would kill his music career.

Mill supporters were outraged at the sentence’s length, comparing it with other high-profile criminal cases that yielded shorter or no prison time.

“More proof that our criminal justice system is a joke,” Philadelphia Eagles wide receiver Torrey Smith tweeted. “Throwing folks in jail for 2-4 years for misdemeanor violations is just a waste of money . . . too long.”

“It’s like this double standard justice system man is just . . . I don’t even have the words now y’all. #FreeMeek,” Questlove tweeted.

“Praying for my brother Meek Mill right now,” Kevin Hart wrote on Instagram. “God sometimes puts the toughest battles on his strongest shoulders.”

“Saddened, angered, and disappointed,” tweeted Hot 97 DJ Peter Rosenberg.