A Borders sheriff has broken step on sentencing rules and criticised the policy in Scottish courts towards domestic abuse cases.
Sheriff Kevin Drummond said it was a "grave wrong" prosecutors could not judge cases on their individual merits.
His comments came as he granted an absolute discharge to a man who had admitted assaulting his partner.
The Crown Office said there was presumption to prosecute in violent cases but discretion could be used.
Sheriff Drummond had claimed all domestic abuse cases were treated in the same way, regardless of the severity of offence.
The policy stems from a national protocol on domestic abuse agreed between the Crown Office and the Association of Chief Police Officers in Scotland (Acpos).
Sheriff Drummond took the unusual step at Selkirk Sheriff Court of granting an absolute discharge to Trevor Shiels, who had admitted assaulting his partner Gail Gold by pushing her on the body to her injury.
The 30-year-old previously had sentence deferred for good behaviour for four months when he first appeared from custody in connection with the offence.
But after considering a letter from Ms Gold explaining that she had not wanted him to be prosecuted, Sheriff Drummond granted an absolute discharge even though he admitted it was "not competent" to do so.
The court was told that when an accused has sentence deferred for good behaviour, there must be a sentence at the end of it, whether that is an admonition or a fine.
But by granting an absolute discharge, this will not show up on Shiels' record.
Sheriff Drummond said: "This is the kind of case where there might be a bit of discretion exercised.
"But as a result of the policy agreed with the Association of Chief Police Officers in Scotland, prosecutors treat every case the same.
"My job is to do justice which is why I am granting an absolute discharge."
However, a Crown Office spokeswoman said: "Prosecution policy is a matter for the Crown Office and Procurator Fiscal Service.
"As a society, we need to take domestic abuse seriously, and that is why we have a presumption in favour of prosecuting cases where there is sufficient evidence of violence.
"Our policy on domestic abuse is robust in order to ensure that crimes of this nature are dealt with sensitively, effectively and in the public interest."
This is the second time Sheriff Drummond has attacked the policy.
Recently, he criticised the protocol from the bench at Duns Sheriff Court after dealing with a case involving a man who was admonished for assaulting his partner. The couple have since married.