The law, introduced by the Justice Minister Naomi Long in 2021, granted anonymity to suspects for up to 25 years after death.
On Friday, Mr Justice Humphreys told the High Court in Belfast that the relevant sections were “not law” and failed to strike a fair balance between suspects’ rights to privacy and press freedom.
He told the court that the legislation was not in accordance with law and that the Northern Ireland Assembly had acted outside “the margin of appreciation afforded to it in this field”.
The judge also said the law imposed a “chilling effect” on public interest journalism.
Ms McLaughlin had lobbied the Minister repeatedly to revisit the legislation, outlining the impact on victims.
Said Foyle MLA: “This decision will come as welcome news to all those concerned about this recent legislation, particularly the victims’ groups who had lobbied the Minister but whose concerns had fallen on deaf ears.
“I have met with the Minister directly outlining my party’s concerns about the impact this legislation has had and repeatedly lobbied Minister Long on this matter through Written Questions, but no action was taken as a result.
“Of course, it is disappointing that this decision had to be taken by the High Court and not the Justice Minister herself.
“I know that many people are concerned that the justice system is abjectly failing in many instances to properly protect victims of sexual offences and give them the support they need as they navigate the system.
“While this is a complex and difficult area of legislation, it is clear that this law had the unintended effect of protecting those who carry out sexual offences, even in death.
“Everyone has the right to be presumed innocent until proven guilty, but this legislation went far beyond that, hampering our press when it comes to uncovering incidences of sexual abuse.
“Lessons must be learned from this legislation so that any future proposals are properly developed and their impacts are widely known and understood.”