David Beeley, 44, decided to confront a gang of drunken teenagers who attacked his home with metal weapons in the middle of the night last summer.
He grabbed a cooking knife to defend himself as they shouted that they planned to kill him. But although none of the gang was prosecuted, Mr Beeley was charged with possession of a knife.
Today, prosecutors came under fire from judge, Michael Stokes, QC, who was highly critical of the decision to charge the logistics manager.
Describing the householder as being of "good character", the Recorder of Nottingham asked: "Which genius thought it was in the public interest to prosecute this defendant?"
Mr Beeley had admitted one count of "having an article with a blade in a public place", to avoid the stress of a trial, Nottingham Crown Court heard.
But the judge sentenced him to a six month conditional discharge, meaning Mr Beeley will not face any punishment.
Tonight, the Crown Prosecution Service (CPS) defended their decision to pursue the case, insisting that officials had properly "considered the evidence in the case and the public interest".
He was also charged with a "summary offence" of "using threatening, abusive or insulting words or behaviour with intent to cause fear or provoke violence".
Outside court Mr Beeley admitted he had made a "bad decision" and should not have confronted the gang with a knife.
"I was a little bit rankled because of the aggression I received, but I shouldn't have done that, it was a bad decision," he said.
"I just want to put it behind me really. It went on for months, and I had to go to court several times."
It is understood that none of the youths, a group of squatters who were armed with "metal implements", have been prosecuted.
"I was a little bit disappointed by that because you wonder whether they will go on to do something else," Mr Beeley added.
"I'm disappointed with the reaction of the police that night. And I agree with what the judge said. It was nice to see a judge with a sense of humour."
Andrew Tanser, prosecuting, had earlier told the court that the defendant was asleep at 11.30pm on August 13 when he was awoken by several drunken teenagers shouting outside his front door.
After yelling at the gang to be quiet, the yobs, who were "rowdy and clearly in drink", shouted at Mr Beeley before later returning with weapons and banged on the door to his home, a large Victorian detached house in which has been divided into flats.
Mr Beeley, lives alone in a second floor apartment, went downstairs, picked up an "ordinary kitchen knife", he had used to cook dinner earlier that night, and went out to confront the gang, who later fled.
Police were called and Mr Beeley, from Mapperley Park, a suburb in the city's north-east, was arrested and charged.
James Whiting, 29, a friend and neighbour, said he was stunned when police arrived and arrested Mr Beeley but took no action against the gang.
Mr Whiting said: "It was unbelievable. There was about four or five of them. They were squatting up the road, and we had no end of trouble with them.
"They would just hang around outside. They wouldn't move and stopped me coming in. They were just yobs."
He said they were taking "running kicks" at this door, shouting they would "kill Dave, and that he couldn't hide in there". He said Mr Beeley was just waving the knife around to "scare them off".
He said the gang had told police that Mr Beeley had "started it" but said that wrong. None of the neighbours were interviewed.
He added: "Now Dave has got a criminal record, and they got away scot-free. A few weeks later they were all involved in a big brawl in the road and moved on."
Tonight, a CPS spokesman defended the charges, insisting that the unnamed prosecutor had "considered the evidence in the case and the public interest".
She added: "The evidence provided showed that the defendant had left his apartment building carrying a large kitchen knife with the intention of making a group of youths who were causing a disturbance leave the vicinity.
"The prosecutor took the view that going out in public with a knife can often inflame a situation, rather than resolve it.
"The defendant pleaded guilty to this offence, on the basis that he had the knife in his hand because he had been cooking and had gone outside out of fear for himself and other residents in the block. This plea was accepted by the prosecution."
A Nottinghamshire Police spokesman said that the decision to charge Mr Beeley was down to the CPS based on evidence from officers. She could not say if others had been charged.
The judge, 64, who was unavailable for comment tonight, has previously criticised prosecutors over cases including that of a teacher was cleared of attempting to murder a 14-year-old pupil who was beaten over the head with a dumbbell.