How does a man walk free and smile after leaving court with a conviction for a crime under the Terrorism Act (2000) only to be greeted by a cheering crowd bearing flowers, chocolates and hugs?

In November last year, CAGE's International Director, Muhammad Rabbani, was stopped and detained by police at London Heathrow airport under controversial Schedule 7 powers which allow officers to detain, question and search travellers at ports of entry in the UK without any reasonable suspicion of criminal conduct.

My colleague had just returned from a trip to the Gulf where he'd taken sensitive testimony from a client who'd made very serious torture allegations against the US. This information was stored on Rabbani's digital devices with a view to pursuing legal action on the client's behalf. When asked by the police to divulge the passcodes to these devices Rabbani refused. Subsequently, he was arrested and, several months later, charged with "wilfully obstructing or seeking to frustrate a search examination". Rabbani called the experience a "digital strip search".

OPINION: 'I am willing to go to prison for privacy for us all'

Over half a million people have been stopped under Schedule 7 - nearly 80 percent of those from ethnic minorities. Up to 85,000 people are stopped every year. The reasoning behind the law is purportedly to prevent terrorists entering the UK, but numbers show that the net is enormous while the catch minuscule. Last year, only 0.02 percent of those stopped were arrested, let alone charged or convicted of terrorist offences.

At CAGE, we have been campaigning against the intrusive and invasive nature of Schedule 7 for years; many of our staff and volunteers are customarily detained under this law. When Rabbani took the decision of refusing to cower in front of this abuse of power he knew that he'd have to pay a price - even if it meant prison. We knew we had another fight on our hands.

The last time I attended Westminster Magistrates Court was in March 2013, when I was brought in a convoy of police cars with flashing lights and blaring sirens and taken, handcuffed, to hear charges of terrorism levelled against me. As I sat in the dock, I looked to my right and saw several people seated in the public gallery who'd come to show their support and smiled. One of them was Muhammad Rabbani. In that moment, neither of us could have imagined that we would be exchanging places soon enough.

As Rabbani sat in the dock on Monday morning listening to the charges read out against him, he briefly looked towards me seated in a packed public gallery and smiled.

In court, defence counsel, Henry Blaxland QC, explained how Rabbani had been stopped and questioned multiple times under Schedule 7. He had been generally cooperative but had, on occasion, refused to disclose his passwords - without further incident. One of those stops occurred in 2013, when he and I were travelling together to Doha, the court heard. The police had threatened me with arrest for failing to answer their questions and hand over passwords to electronic devices.

One of the terribly frustrating things I found after being questioned by police officers at airports is their lack of understanding and comprehension of the huge powers at their disposal. This couldn't have been more evident than when Blaxland cross-examined PC Tariq Choudary, the principal officer involved in Rabbani's questioning.

READ MORE: CAGE's Muhammad Rabbani to appeal against court ruling

Perhaps he was just nervous, but Choudary's answers were incoherent, incomprehensible and embarrassing. After being repeatedly told by the magistrate to speak up, Choudary found himself refusing to answer fairly mild questions. Blaxland asked if police stops were generally based on specific information, whether Rabbani's was such a case and if he'd ever come across a case where someone had refused to submit his password? To each question, Choudary replied: "I cannot confirm or deny that." During awkward moments of silence, the magistrate had to intervene and explain that he could answer the questions, especially since the prosecution was not objecting. Many of these exchanges were followed with sharp intakes of breath and open laughter in the gallery. What dawned on most of the people in attendance was the pitiful nature of the police officers charged with protecting our borders, and yet they are granted to so much power.

There is no evidence to suggest that Schedule 7 has made the country safer in any way.

Blaxland further asked Choudary if he'd informed Rabbani regarding provisions within the Code of Practice that he had the right not to disclose confidential material - given Rabbani's job and the role of CAGE as rights NGO. Choudary essentially replied by saying that he could only determine whether the information was confidential (excluded material) after he'd accessed it. In other words, the police can only inform you of your right of confidentiality once they've violated it.

Despite the troubling nature of this particular case, some would argue Schedule 7 is a necessary inconvenience in troubled times and an integral part of the fight against terrorism. There is no evidence to suggest that Schedule 7 has made the country safer in any way. In fact, we believe that latent religious and racial prejudices evident in the application of this power further alienates and negatively radicalises people.

The court heard about the intrusive nature of Schedule 7 but was not equipped to address it. Rabbani was convicted under terrorism laws for simply failing to provide his passwords. He will, of course, appeal the decision but, the greatest loser in this first round has been Schedule 7 and its invisible supporters. Britain in 2017 calls people who don't give their passwords to the police, "terrorists". For the rest of us, the ramifications for our right to privacy and guarding confidential information will now be put to the test. For Muhammad Rabbani, his was a brave act of civil disobedience, long overdue. He fought to expose the unjust nature of this law and passed with flying colours.

That's how a man convicted of terrorism walks free from court. Like a hero, with a smile on his face.

Moazzam Begg is a former Guantanamo Bay detainee and director of outreach for the UK-based campaign group CAGE.

The views expressed in this article are the author's own and do not necessarily reflect Al Jazeera's editorial policy.