Advocating the abolition of the monarchy in print is lawful and no one can be prosecuted for it, despite a 19th-century act still on the statute book that bans it, five law lords confirmed yesterday.

Judges in the Lords said the Guardian had acted lawfully in its campaign calling for a referendum on whether Britain should become a republic.

Lord Scott said the paper, which challenged the lawfulness of the Treason Felony Act 1848, could regard the law lords' unanimous endorse ment as "a successful outcome to their litigation".

But the Guardian technically lost the case, because the judges ruled the litigation unnecessary. It was perfectly clear, they said, that the ban in the 1848 act could not survive the Human Rights Act 1998, and that no one could be prosecuted under it.

It was for parliament, not the courts, to get rid of outdated statutes. Therefore they refused to send the case back to the high court for a declaration that the ban breached human rights law.

The Guardian argued that the 1848 act, which makes it a crime punishable by life imprisonment to call for an end to the monarchy even by peaceful means, breached article 10 of the European convention on human rights, which guarantees freedom of expression.

In December 2000 Alan Rusbridger, the Guardian's editor, sought an assurance that Lord Williams of Mostyn, then attorney general, would not prosecute the paper for the campaign it was about to launch. But he refused to give an assurance.

The paper argued that the threat of prosecution had a "chilling effect" on free speech and sought a declaration that the act was incompatible with the European convention, or should be read as banning only calls for the overthrow of the monarchy by force.

It lost in the high court but at appeal won the right to seek a declaration that the ban was no longer valid.

However, after an appeal by the next attorney general, Lord Goldsmith, the law lords said it was clear the law had not affected the freedom of expression of the paper, since it had published the articles anyway.

"Given that the editor did publish articles advocating a republic, the argument was threadbare," said Lord Steyn.

"Clearly, the editor of the Guardian has not slept uneasily in his bed for fear of being prosecuted under section three of the 1848 act." No one has been prosecuted under section three for more than 100 years.

Lord Scott said it was "plain as a pike staff" that advocating peaceful abolition of the monarchy did not risk prosecution.

The Human Rights Act required the 1848 act to be read in such a way that advocacy of republicanism was not a criminal offence. "No attorney general or director of public prosecutions would, or could, authorise prosecution ... without becoming a laughing stock."

Lord Scott said there would surely have been no litigation if the attorney general had replied to the editor's letter saying, "in a mature democracy people do not get prosecuted for advocating political change by peaceful and constitutional means".

Lord Walker said the act was "a relic of a bygone age". He added: "In my opinion it is most undesirable that obsolete statutes remain unrepealed."

But the Human Rights Act was not "an instrument by which the courts can chivy parliament into spring cleaning the statute book".

Mr Rusbridger commented: "Although the attorney general has won this appeal, we are delighted that the Lords' ruling unanimously vindicates the Guardian's position: that this anachronistic law is incompatible with the Human Rights Act and should be repealed.

"This judgment makes clear that advocating a republic can no longer be considered a treasonable act.

"The government should now scrap this law - which is still cited by thugs in clamping down on the press. If the attorney general had made a statement of the obvious two years ago the litigation would not have been necessary."