The Metropolitan Police has been criticised for the way it used stop and search powers on two protesters near an arms fair in London's Docklands.
Police have search powers under the Terrorism Act 2000
The Lord Chief Justice described the actions of police as "lamentable".
But, with two other Court of Appeal judges, he upheld the government's right to authorise searches.
The judges neither upheld nor dismissed an appeal by Kevin Gillan and Pennie Quinton against the police's right to search them under anti-terror laws.
The pair had a challenge turned down by the High Court in October last year.
Lord Chief Justice Lord Woolf called on the police force to "review very carefully" how the powers were exercised as the briefing given to officers on the ground was poor.
He said: "It is important that, if the police are given exceptional powers, they are prepared to demonstrate that they are used with appropriate circumspection."
Since February 2001, the home secretary can authorise the Metropolitan Police to make random searches under section 44 of the Terrorism Act 2000.
'Use of the power'
The two demonstrators were on their way to an arms fair in London's Docklands when they were stopped by police last September.
After nothing incriminating was found on them police allowed them to continue on their way, but the pair said the use of the stop-and-search power interfered with their human rights.
Lord Woolf, sitting with Lord Justice Buxton and Lady Justice Arden, said: "Given the scale of the current terrorist threat, the powers under the Act cannot be said to be an unreasonable intrusion into the human rights of those who were searched.
"The disadvantage of the intrusion is outweighed by the advantage that accrues from the possibility of a terrorist attack being foiled by the use of the power."
Lawyers for the Metropolitan Police and the home secretary said they did not seek costs against the complainants because the case had raised issues of public importance.
The Home Office said it welcomed the court's decision.
A spokeswoman said: "We accept that these are strong powers, and this is why there are robust safeguards in place to ensure these powers are used appropriately by the police.
"The Home Secretary takes the use of these powers very seriously and he would only confirm an authorisation which he considered was a necessary and proportionate response to the terrorist threat."
She described the powers as "invaluable" and "essential" in the "ongoing fight against terrorism".
Met Police Deputy Commissioner Sir Ian Blair said the powers were "vital in keeping London safe" and that the exhibition had been identified as a potential terror target.
He said: "The key thing here is that section 44 is a power we use to put off
"They know they can be stopped and searched in London and we are going to
continue to use that power."
When asked if he felt the powers infringed on human rights he said: "The most vital human right is the right to life."
A statement from the Metropolitan Police Service (MPS) said following an internal review briefing, documentation and supervision of the use of section 44 powers had been improved.
Shami Chakrabati from human rights group Liberty said Lord Woolf did not go far enough in his judgement.
She said: "It's great that he has made it clear that these are exceptional powers and the burden must clearly be on the police to act lawfully and to justify any stop and search.
"However he's also allowed what he's described as rolling and blanket stop and search powers to continue and he hasn't taken the opportunity to give any real guidance to Parliament of the home secretary."