The former top media adviser to Prime Minister David Cameron was detained Wednesday on suspicion of perjury in the trial of a flamboyant ex-Scottish lawmaker — the latest case tied to allegations of wrongdoing by British tabloid newspapers.

Andy Coulson, 44, was detained by Scottish police at his home in London over an accusation related to testimony he gave in a high-profile case at Glasgow's High Court in 2010, when politician Tommy Sheridan was himself convicted of offering a false account in a legal hearing.

Sheridan had won a lawsuit against the now-defunct News of The World tabloid over its claim that he was embroiled in a sex-and-drugs scandal, but was later jailed for three years after a jury at the 2010 trial ruled that he had committed perjury when he sued the newspaper.

Coulson was editor of the tabloid when stories about Sheridan were published, and working as Cameron's communications director when he gave evidence to the 2010 trial.

The ex-aide, who left his post at the News of The World in 2007 after a reporter and a private investigator were jailed over phone hacking offenses, told the court that he didn't "accept there was a culture of phone hacking" at the tabloid.

He insisted that he had ordered his reporters to work within the law and said that police officers were not paid for information.

Those assurances have since been called into question by revelations of widespread illegal behavior at the paper and allegations — denied by Coulson — that he approved and encouraged the shady practices.

Cameron has insisted he had been right to offer Coulson a "second chance," by making him his media chief — but the ex-aide's resignation early last year, his arrest by London police investigating phone hacking, and Wednesday's detention by Scottish police have raised questions about the British leader's judgment.

The prime minister's ties to both Coulson and their mutual friend Rebekah Brooks, an ex-chief executive of Rupert Murdoch's News International, have brought the tabloid phone hacking scandal to Cameron's doorstep.

Sheridan, who was freed from jail after serving a year of his sentence — usual practice for crimes of that type in Scotland — said he now hopes to have his conviction quashed.

"We were led to believe by Mr. Coulson and his acolytes at News International during my trial and the initial phone-hacking investigations that the problem was a rogue reporter," Sheridan told reporters outside his home. "Well, I think we all know now that there is no bad apple in the barrel. What there is is a rotten orchard full of bad apples."

Sheridan's lawyer, Gordon Dangerfield, said he would now appeal the ex-lawmaker's perjury conviction.

In 2006, Sheridan won a defamation suit against the tabloid after it claimed he had visited a swingers' club, had taken part in orgies and used cocaine. However, a year after his courtroom victory against the newspaper, police arrested and charged Sheridan with perjury in connection with the hearing.

The subsequent trial riveted Scotland, with its lurid allegations about sex clubs and tabloid skullduggery.

Coulson arrived in Scotland on Wednesday afternoon for questioning there, but had not yet been formally arrested. In Scotland, which uses a different legal system from the rest of Britain, a suspect can be detained by police to answer questions before being formally arrested.

The police department said the case was tied to Operation Rubicon, a Scottish police investigation into allegations of phone hacking, breaches of data protection and perjury. Those inquiries are running separately to major investigations by London police into newspaper malpractice.

Coulson is currently on police bail in connection with the London inquiry, meaning he must return to answer more questions from detectives there in the near future. He has also testified to the country's media ethics inquiry.