An undercover police officer posing for years as an environmental activist co-wrote a libellous leaflet that was highly critical of McDonald's, and which led to the longest civil trial in English history, costing the fast-food chain millions of pounds in fees.

The true identity of one of the authors of the "McLibel leaflet" is Bob Lambert, a police officer who used the alias Bob Robinson in his five years infiltrating the London Greenpeace group, is revealed in a new book about undercover policing of protest, published next week.

McDonald's famously sued green campaigners over the roughly typed leaflet, in a landmark three-year high court case, that was widely believed to have been a public relations disaster for the corporation. Ultimately the company won a libel battle in which it spent millions on lawyers.

Lambert was deployed by the special demonstration squad (SDS) – a top-secret Metropolitan police unit that targeted political activists between 1968 until 2008, when it was disbanded. He co-wrote the defamatory six-page leaflet in 1986 – and his role in its production has been the subject of an internal Scotland Yard investigation for several months.

At no stage during the civil legal proceedings brought by McDonald's in the 1990s was it disclosed that a police infiltrator helped author the leaflet.

The McLibel two: Helen Steel and David Morris, outside a branch of McDonald's in London in 2005 after winning their case in the European court of human rights. Photograph: Martin Argles for the Guardian

A spokesman for the Met said the force "recognises the seriousness of the allegations of inappropriate behaviour and practices involving past undercover deployments". He added that a number of allegations surrounding the undercover officers were currently being investigated by a team overseen by the chief constable of Derbyshire police, Mick Creedon.

And in remarks that come closest to acknowledging the scale of the scandal surrounding police spies, the spokesman said: "At some point it will fall upon this generation of police leaders to account for the activities of our predecessors, but for the moment we must focus on getting to the truth."

Lambert declined to comment about his role in the production of the McLibel leaflet. However, he previously offered a general apology for deceiving "law abiding members of London Greenpeace", which he said was a peaceful campaign group.

Lambert, who rose through the ranks to become a spymaster in the SDS, is also under investigation for sexual relationships he had with four women while undercover, one of whom he fathered a child with before vanishing from their lives. The woman and her son only discovered that Lambert was a police spy last year.

The internal police inquiry is also investigating claims raised in parliament that Lambert ignited an incendiary device at a branch of Debenhams when infiltrating animal rights campaigners. The incident occurred in 1987 and the explosion inflicted £300,000 worth of damage to the branch in Harrow, north London. Lambert has previously strongly denied he planted the incendiary device in the Debenhams store.

While McDonald's won the initial legal battle, at great expense, it was seen as a PR disaster. Photograph: Image Broker/Rex Features

Lambert's role in helping compose the McLibel leaflet is revealed in 'Undercover: The True Story of Britain's Secret Police', which is published next week. An extract from the book will be published in the Guardian Weekend magazine. A joint Guardian/Channel 4 investigation into undercover policing will be broadcast on Dispatches on Monday evening.

Lambert was one of two SDS officers who infiltrated London Greenpeace; the second, John Dines, had a two-year relationship with Helen Steel, who later became the co-defendant in the McLibel case. The book reveals how Steel became the focus of police surveillance operations. She had a sexual relationship with Dines, before he also disappeared without a trace.

Dines gained access to the confidential legal advice given to Steel and her co-defendant that was written by Keir Starmer, then a barrister known for championing radical causes. The lawyer was advising the activists on how to defend themselves against McDonald's. He is now the director of public prosecutions in England and Wales.

Lambert was lauded by colleagues in the covert unit for his skilful infiltration of animal rights campaigners and environmentalists in the 1980s. He succeeded in transforming himself from a special branch detective into a long-haired radical activist who worked as a cash-in-hand gardener. He became a prominent member of London Greenpeace, around the time it began campaigning against McDonald's in 1985. The leaflet he helped write made wide-ranging criticisms of the company, accusing it of destroying the environment, exploiting workers and selling junk food.

Four sources who were either close to Lambert at the time, or involved in the production of the leaflet, have confirmed his role in composing the libellous text. Lambert confided in one of his girlfriends from the era, although he appeared keen to keep his participation hidden. "He did not want people to know he had co-written it," Belinda Harvey said.

Paul Gravett, a London Greenpeace campaigner, said the spy was one of a small group of around five activists who drew up the leaflet over several months. Another close friend from the time recalls Lambert was really proud of the leaflet. "It was like his baby, he carried it around with him," the friend said.

When Lambert's undercover deployment ended in 1989, he vanished, claiming that he had to flee abroad because he was being pursued by special branch. None of his friends or girlfriends suspected that special branch was his employer.

It was only later that the leaflet Lambert helped to produce became the centre of the huge trial. Even though the activists could only afford to distribute a few hundred copies of the leaflet, McDonald's decided to throw all of its legal might at the case, suing two London Greenpeace activists for libel.

Two campaigners – Steel, who was then a part-time bartender, and an unemployed postal worker, Dave Morris – unexpectedly stood their ground and refused to apologise.

Steel and Morris outside the high court at the start of the first proceedings in the McLibel trial in 1990. Photograph: Photofusion/UIG/ Getty Images

Over 313 days in the high court, the pair defended themselves, with pro bono assistance from Starmer, as they could not afford to hire any solicitors or barristers. In contrast, McDonald's hired some of the best legal minds at an estimated cost of £10m. During the trial, legal argument largely ignored the question of who wrote the McLibel leaflet, focusing instead on its distribution to members of the public.

In 1997, a high court judge ruled that much of the leaflet was libellous and ordered the two activists to pay McDonald's £60,000 in damages. This sum was reduced on appeal to £40,000 – but McDonald's never enforced payment.

It was a hollow victory for the company; the long-running trial had exposed damaging stories about its business and the quality of the food it was selling to millions of customers around the world. The legal action, taking advantage of Britain's much-criticised libel laws, was seen as a heavy handed and intimidating way of crushing criticism. However, the role of undercover police in the story remained, until now, largely unknown.

On Friday, Morris said the campaign against the burger chain was successful "despite the odds overwhelmingly stacked against us in the legal system and up against McDonald's massive and relentless advertising and propaganda machine.

"We now know that other shadowy forces were also trying to undermine our efforts in the most disgusting, but ultimately futile ways. All over the world police and secret agents infiltrate opposition movements in order to protect the rich and powerful but as we have seen in so many countries recently people power and the pursuit of truth and justice is unstoppable, even faced with the most repressive and unacceptable Stasi-like tactics."