Two children lived in an alleged methamphetamine lab and were exposed to the criminal underworld because their father's "cries for help" to CYF were ignored.
A Family Court judge criticised the government department for a string of failures in the custody battle and took the "exceptional" step of placing the siblings, aged 8 and 15, under her guardianship.
The father made repeated warnings about the new partner of his former wife but his "cries for help have fallen on deaf ears," according to Judge Belinda Pidwell.
His two children were living with their mother and a 34-year-old man previously jailed for possession of methamphetamine and firearms, including an AK-47.
He was then arrested for possession of equipment to manufacture methamphetamine in February 2014 and released on bail.
The children's father feared for their safety but his concerns were dismissed by the CYF social worker, who accepted the explanation given by the new partner.
"[The accused] was honest about his charges. It is my view these charges are not an area of concern regarding the children's safety," the social worker wrote.
Later that year, CYF was given a police intelligence report detailing his criminal history and described as a "person of interest" to the drug squad's Asian Organised Crime unit.
Safety concerns for the children were also raised by Dr Sarah Calvert, a child psychologist appointed as the Court's expert for the case, in December 2014.
She was also watched by men in several cars outside the address.
But the children continued to live with the convicted criminal, despite this being a breach of his bail conditions, until armed police raided the South Auckland home in July 2015.
During this time, his Audi was set on fire while parked on the driveway of the home in an arson attack.
He was one of seven people arrested in a covert investigation and the police allege methamphetamine was manufactured at the address where the children were living.
Three of those charged were living at the address with the children, although they later tested negative for traces of P.
The alleged ringleader has since pleaded guilty to the 2014 charges, and been jailed for two years, but is yet to stand trial on the more serious charges.
He has pleaded not guilty to manufacturing methamphetamine, supplying methamphetamine and being a member of an organised criminal group.
Several luxury cars, registered in the name of the mother, have been seized by police under the proceeds of crime legislation.
But even after his second arrest, CYF sided with the mother of the children.
The father, at one point the subject of protection orders which were later discharged, was described as "difficult" and a "larger than life" character during the Family Court proceedings.
"[The father] has been categorised as a pest and a nuisance. It is likely the authorities have considered his actions may jeopardise ongoing investigations. However it is a parent's primary responsibility to ensure that their child is safe," Judge Pidwell wrote in her decision.
"All of [the father's actions], which have eventuated in his suspicions being vindicated, must be seen in that light."
In contrast, Judge Pidwell said the social workers took the mother's assurances she had cut ties with her partner at face value.
She supported him at one of his court appearances, offered her home as a potential bail address and visited him in prison just two weeks before the custody hearing in the Family Court.
"[The mother] showed an alarming lack of insight into the risks that she has exposed her children to by virtue of her association with [her partner]," said Judge Pidwell.
"The choices she has made over the past two and a half years have not promoted the children's best interests and welfare. Her choices have placed them in a position of extreme risk and created the intractable position of the parties to date."
Her ongoing denial of the risk was "supported" by CYF, said Judge Pidwell, which did not impose any consequences for the mother for failing to cut ties with her partner.
The father sought sole custody of both children, which was opposed by CYF.
While the younger child, now 8, was happy in his care, the 15-year-old daughter did not want a relationship with him.
Dr Calvert said the father presented as an "angry, frustrated father whose very real concerns for his children had continually not been heard."
His daughter's reluctance to have contact with her father was driven by being in the middle of the conflict between her parents, because the mother has "placed the children in a position where they are covering up and lying for their mother which has created high levels of anxiety in both children."
"The only way for her to cope with that anxiety was to shut down all contact with her father," Judge Pidwell said of Dr Calvert's opinion of the daughter.
"Dr Calvert expressed concerns about the quality of social work undertaken in this matter, and the failure of CYFS to take the appropriate steps when it was clear the children were in a position of danger," said Judge Pidwell.
"Her view is that these children have been exposed to risk for many years and she is highly concerned that no one was attending to their ongoing care and protection.
"She noted that there were serious safety concerns for everybody involved in this family in this case, including her.
"Indeed [Dr Calvert] had been 'observed' while conducting interviews by two car-loads of persons outside [the mother's] home."
However, CYF maintained the children should remain in the care of their mother until halfway through the Family Court hearing, when the lead social worker was being cross-examined by the father.
Judge Pidwell said this demonstrated a lack of "insight into the substantive and complex issues in this case".
"Due to the failures of the Ministry to date and also the lack of faith [the father] justifiably has in their ability to protect the children from ongoing exposure to harm, neglect and impairment, I consider that the only option for these children is to place them under the guardianship of the Court.
"That is the highest level of control over children that the law can offer. These circumstances are exceptional."
In a later order, she ruled the son should live with his father but the daughter - who didn't want contact with her father - was to stay with her mother under close monitoring by CYF, which in turn will report directly to the judge each month.
The father plans to appeal this part of the judgment and told the Weekend Herald his sometimes emotional behaviour was driven by the desire to protect his children from known criminals.
He was frustrated by the inaction of CYF, particularly after his concerns were vindicated, and his health and finances had suffered as a result of the stress.
"There are so many clowns in this circus. This is not a custody battle, I just want to keep my kids safe."
In a statement, the regional director for CYF in Auckland Sue Jarvis said the case was a "complex and challenging" family situation where the custody and care arrangements for the children have been contested by their parents since they separated some years ago.
"There has been a number of professionals providing advice and support in this case. The decision-making has been guided by their views of the children's situation, the impact of the family dynamic as well as the voices of the children themselves."
CYF took the judge's concerns seriously but Jarvis said "things have moved on since then" and this is reflected in the judge's subsequent directions to allow the teenage daughter to stay with her mother.
She was unable to comment further because of the possible appeal.
The Minister for Social Development Anne Tolley said she would expect CYF to review any cases where the appropriate course of action was not taken.
"I expect CYF to do the very best for children in every case they deal with, no matter how complex and challenging, and I know they are committed to doing this."