As Jim Sutton stood up in court he seemed to all the world a committed environmental campaigner. In the witness box, he affirmed under oath his name and address.

Still under oath, he then gave evidence, under questioning from barristers, seeking to clear himself and seven other campaigners accused of disorderly behaviour during a demonstration. He told the court he had wanted to unfurl a banner from the window of a government building to promote their cause.

But what the campaigners and lawyers at London's Horseferry Road magistrates' court that day could not have realised was that a fictitious man was being prosecuted. According to the solicitors who represented Sutton, the court was hearing evidence from a man who did not exist.

The quiet man purporting to be an ardent activist working as a cleaner was in reality an undercover police officer who had been infiltrating political movements for some time as part of a long-standing operation to garner intelligence on campaigners. His real name was Jim Boyling and he was employed by a covert Scotland Yard unit specialising in monitoring political activists.

Revelations about the deployment of police spies in protest groups have provoked controversy this year, but the latest allegations may be the most damaging. Police chiefs now stand accused of authorising their undercover officers to give false identities in a deliberate manipulation of the legal system.

They are under pressure to explain how often they may have sanctioned officers to deliberately mislead judges and magistrates and break the law in their courtrooms.

One undercover officer prepared to speak out claims the Boyling case was not a one-off. Pete Black, who worked alongside Boyling in the covert unit monitoring political campaigners, told the Guardian that undercover operatives were often prosecuted under their fake identities, as it helped to foster their credibility as genuine campaigners.

Andrew James Boyling's astonishing double life started around 1995, when he was sent to infiltrate hunt saboteur campaigners. Black, who was concentrating on penetrating anti-racist groups, mentored Boyling in the arts of masquerading as an activist.

By the following year, Boyling was spying on a group known as Reclaim the Streets, who took over public roads and staged imaginative parties in protest against the domination of cars. Boyling established himself as a trusted member of the campaign, who could be relied upon to turn up at its protests and weekly meetings. "He was totally deeply embedded in the whole social network as well. Meetings often happened in the top room of a pub so he would be there and end up living with people," said one activist.

Boyling was described as reticent and "a nice bloke", a fitness fanatic who did not take part much in political discussions but who had an asset unusual among the environmental campaigners: a van. He used it to transport equipment for demonstrations from, for instance, activists' homes.

On 7 August 1996, hundreds of activists cycled around Trafalgar Square in London to bring traffic to a standstill in support of a strike by Tube workers. Boyling, known as "Jim the Van", was among a group of protesters who then occupied the nearby office of the chairman of London Transport. His legal journey from arrest to court has been pieced together by activists and their lawyer, Mike Schwarz of the law firm Bindmans, after Boyling was exposed as a police spy by the Guardian in January.

Surviving records show a group of campaigners got into the headquarters of Transport for London and up to the chairman's office on the seventh floor. PC David Casson testified that he and a colleague had subsequently "removed a male I now know to be Peter James Sutton and a female. Sutton was holding a large pink and white coloured banner out of the window". They were said to be the last to be escorted from the office.

Boyling, under his Sutton alias, would later tell the trial "we felt the intention was to unfurl the banner as we felt it would be of interest to the media", according to a legal note taken by the court clerk. It read "Don't Squeeze the Tube".

The prosecution claimed the protesters had pushed past security guards and shoved an employee to the floor while "shouting and screaming and being disorderly". In the witness box "Sutton" rejected these claims and insisted the protesters had been "very civilised", according to the note of his evidence.

Casson testified that "due to the large number of arrests, the nature of the allegation and the possibility of the group escaping, Sutton was handcuffed in the back-to-back position, double-locked, checked for tightness".

At 11.15am, he was arrested and taken to Charing Cross police station, where he declared he was "Peter James Sutton", a cleaner from east London. He gave his date of birth as 24 April 1967, although other official forms record it as 9 March 1965.

Like the other activists, he instructed Bindmans to represent him. A Bindmans lawyer sympathised with him for having "a rather difficult time" at the station as he had been held in custody for more than six hours. He and the others were charged with breaking the Public Order Act.

The three-day trial was told a plain clothes police officer, Christopher Fernot, had been keeping a "watchful eye" on the group of activists, including Boyling, who had broken away from the Trafalgar Square demonstration. He had followed them into the Transport for London office.

The activists were acquitted, although one campaigner, John Jordan, was convicted of assaulting an officer and given a conditional discharge following disputed evidence. Jordan is appealing against his conviction, alleging he did not get a fair trial because of misconduct by the prosecution.

He alleges that the campaigners' confidential discussions with their lawyers were "blatantly breached as a result of apparently authorised executive action". He also says "the undercover officer played a major role in initiating conduct which was then prosecuted".

Activists say the courtroom deception helped to bolster Boyling's position in the group and he had burrowed himself into the inner core of the group by 1999. That year, he fell in love with another Reclaim the Streets activist and moved in with her. But he became more and more moody and then in September 2000 he suddenly left. He told her he was going to Turkey and then South Africa, but disappeared.

In a detailed account, she has told the Guardian how she spent more than a year trying to find him and his relatives who, she discovered, did not exist. She spent her savings travelling abroad in search of him. Eventually she bumped into him by chance in the London bookshop where she was working.

Boyling told her he was a police officer. They later married and had two children before divorcing two years ago. The woman, who was not named by the Guardian, claimed Boyling encouraged her to change her name by deed poll, seemingly to hide their relationship from his bosses. She also alleged that he only notified his superiors of his relationship with her in 2005, around the time they married under her new identity. She further alleged that Boyling had identified at least two other undercover officers. Following the claims, the Metropolitan police launched an investigation and restricted Boyling from his counter-terrorism duties.