A police officer who was secretly recorded calling a young black man under arrest a "nigger" has been cleared by a judge of criminal racist abuse, after a second jury was unable to reach a verdict.

Judge Michael Gledhill QC discharged Alex MacFarlane, a constable based at Forest Gate police station in east London, after the jury could not reach a decision. The first trial, last week, had the same outcome, and prosecutors said they would not take the unusual step of seeking a third trial.

MacFarlane, 53, was in the back of a police van in August last year when he said to the arrested man, Mauro Demetrio, 21: "The problem with you is that you will always be a nigger." Demetrio recorded the comment on his mobile phone.

The audio records the young man's protest, while MacFarlane goes on to say "you will always have black skin colour" and "don't hide behind your colour", and tells him to "be proud" of his race.

An earlier recording made by Demetrio features another police officer in the van, not identified in court, calling him a "scumbag" and a "cunt" and boasting about having throttled him.

Demetrio complained that he had been assaulted. A police doctor found marks on his neck but no charges were brought.

The Crown Prosecution Service (CPS) initially declined to charge MacFarlane, only doing so when Demetrio's lawyers threatened to challenge the decision. Further pressure was placed on the CPS when the Guardian ran a story based on audio recordings made by Demetrio on his phone, the key evidence in the case.

MacFarlane will now face police disciplinary proceedings for potential gross misconduct, a charge for which he could be dismissed. The Independent Police Complaints Commission said it passed its findings to the Metropolitan police in May. Mike Franklin, an IPCC commissioner, said: "Whether his behaviour is a breach of professional standards is something a misconduct hearing will decide upon."

Duncan Atkinson, prosecuting, told the initial trial at Southwark crown court that MacFarlane's comments were intended to insult and "put Mr Demetrio in his place". He said: "It is clear that this abuse was racially motivated, and was targeted and was intended. Such words were designed to cause – and did cause – distress and insult."

After MacFarlane was cleared, Demetrio's mother, Maria Demetrio, said she was "deeply disappointed", adding: "Even though this officer was not found guilty, I hope this case will make other police officers think twice in future before using racist language or abusing their powers."

MacFarlane, an officer for 18 years with a previously unblemished professional record, argued that he was seeking to "defuse the situation" as Demetrio had become agitated and abusive when the officers stopped the car he was driving and arrested him over two outstanding warrants.

MacFarlane and other officers in the van at the time testified that Demetrio had himself been racially abusive, calling police "white cunts" and making sexually explicit threats. None of these alleged comments were on the recordings.

The constable said Demetrio first used "nigger" in reference to himself, in asking why he had been arrested while his white friend was not. Repeating the word was an error caused in part by fatigue from long hours over the preceding days, when he had been involved in policing the riots in London, MacFarlane told the first trial.

In his first testimony from the witness stand, MacFarlane argued that his words were a misguided attempt to turn the young man's life around. "I had formed an impression in my mind that he had low self-esteem," MacFarlane said. "I wanted him to reconsider his lifestyle, to not view his skin colour as the reason behind the problems he had, not to blame the police, not to blame other people."

After the discharge, the defence asked the judge if he had any comments to advise a police disciplinary hearing against MacFarlane. Gledhill said the officer's use of "nigger" was unacceptable but added: "It was said in the heat of the moment in circumstances where the complainant was very abusive."

MacFarlane had denied a racially aggravated public order charge.