A High Court ruling will allow the BBC to publish a story about a man it says exploited his status as an MI5 informant to abuse his partner.
The BBC said the decision will allow it to tell a story that is "firmly in the public interest".
An injunction still bans the corporation identifying the man, known in court proceedings as X.
But in a final ruling, the judge said the BBC can decide which details can be made public without identifying him.
Attorney General Suella Braverman had applied for an injunction preventing X from being identified by the publication of a planned BBC story.
She claimed that - without confirming or denying that he was an MI5 agent - the story could put him at risk of harm or death and jeopardise national security.
The BBC wanted to name the man who it says used his intelligence status to coerce and terrify a former partner and poses an ongoing threat to women.
It argued that MI5 should have known about his behaviour and it was inappropriate to use him as an agent or a covert human intelligence source.
A private section of Wednesday's ruling placed some restrictions on the BBC's reporting.
But in the public judgment, Mr Justice Chamberlain said the "experience and expertise" of the corporation and its experienced investigative journalist meant it was well-placed to make decisions about which other details risked identifying X.
In a statement, the BBC said: "This ruling enables us to tell a story we believe is firmly in the public interest, and it is a vindication of the BBC's investigative journalism."
The BBC is planning to run the story in the coming days.
The attorney general has been asked for comment.