The only sheriff in town brought justice to boxing and to Paulie Malignaggi this weekend.

HBO Sports president Ross Greenburg is not supposed to be in charge of justice or of boxing. His job is to buy fights, not make fights.  He’s in charge of the largest cable budget dedicated to the oft-maligned and often ignored art of prize fighting and that’s about it.

His job is to televise fights, not right the wrongs of incompetent or corrupt judges, shady or inept referees and greedy or worse promoters even though he well understands that shady decisions like the scorecard last weekend that had Sergio Martinez losing 119-110 to Paul Williams in a fight that was tighter than Tiger Woods’ lips are at the moment do boxing no good, either in the short term or the long term.

Yet when he watched tape of the absurd scoring in Malignaggi’s loss on points to former three-time lightweight champion Juan Diaz in August and then began to read the raging storm of criticism he told The Sweet Science, “That 118-110 (scorecard of long inept Texas judge Gale Van Hoy) was on another planet. These kinds of things are terrible for the sport. They have to stop. But a TV network is in a difficult spot. In some ways we are the only ones who can put pressure on because we finance a lot of this stuff…but we can’t start regulating state commissions.’’

Greenburg was right on both fronts but he was most right when he made clear to Diaz’ promoter, Oscar De La Hoya, and Malignaggi’s promoter, Lou DiBella, that if they wanted to fight on HBO any time soon it would be against each other.

For DiBella and Malignaggi this was welcome news but for Diaz’s people not so much. Malignaggi is stylistically difficult for most everyone he faces and particularly for someone like Diaz, who comes straight forward time and again, earnestly throwing punches. He is not known as “The Baby Bull’’ for nothing.

Diaz’  handlers would just as soon have moved on to a rematch with, say, Juan Manuel Marquez, then face Malignaggi, a consummate defensive boxer who is under appreciated by today’s boxing fan, but Greenburg made clear what fight he wanted for HBO.

“I give Ross credit,’’ DiBella said of Saturday night’s Diaz-Malignaggi rematch in Chicago. “Ross was concerned with the perception from those scorecards in Texas. He met with me, Paulie and Paulie’s attorney and he promised he’d do all he could to make the rematch.

“Ross did exactly what he said he’d do. Had he not been supportive of a rematch it would not have happened. Juan would be fighting (Ricky) Hatton or Marquez. Ross is getting sick of this s***. I could see it on his face when they read that scorecard Saturday night in the Martinez fight and the fans started booing.

“That was an American crowd. They didn’t come to Boardwalk Hall in New Jersey to cheer for a guy from Spain. But the fans have had enough and so has Ross. Again, I give him credit. He could have just moved on and left us out in the cold but he didn’t.’’

Greenburg tried to deflect credit for forcing the rematch, saying the fight had been an exciting one that required little pushing to make. Perhaps so, but exciting or not it isn’t a fight Diaz will be looking forward to.

“They had to do it again at a neutral site,’’ Greenburg said. “It was an exciting fight. Look, it made good TV.

“It’s a tough fight for Juan because of the style but there wasn’t a ton of arm twisting that had to be done. We remain a TV network looking to put on the best fights. We’re glad to be bringing a solid fight back to the American public.

“I take a little pride knowing Paulie is getting this second chance and Juan is getting a chance to clear up a controversial win on his record. After this both fighters can sleep at night without having to live with that black mark on their record.’’

So can Ross Greenburg, who got it done, and fans of boxing, who should understand this fight happened because the new sheriff in town drew his fiscal gun and made clear he wouldn’t be firing any greenbacks out of it for anything but a rematch between these two.

HBO executive producer Rick Bernstein, producer Thomas Odelfelt, their staff and the announcing crew will delve into the circumstances surrounding the scoring of the first fight and how it led to this rematch on Saturday, a story line that will remain a theme throughout the night to be sure.

“We’ll be all over that,’’ Greenburg said. “Our announcers will be armed and ready and the story of the mysterious scorecard will be told.’’

Greenburg believes these kind of situations surface in boxing not because of corruption, even though that is what the public suspects, but rather ineptitude and incompetence. Although he says he has no jurisdiction to change that, he believes state commissions should more closely monitor their officials and remove them when there is a pattern of having scorecards that are alarmingly out of sync with what actually happened in the ring.

“In other sports, team sports, the leagues review the officials and their abilities,’’ Greenburg said. “They remove officials they feel are incompetent. They make sure the best officials work the big games.

“This kind of stuff has been going on in boxing for ever but that doesn’t make it right. There has to be some accountability.’’

This time there was. The new sheriff made sure of that.