The High Court in Glasgow heard Miss Spence, who went missing in April 2011, was working as an informer for the Scottish Crime and Drugs Enforcement Agency (SCDEA) and also for the UK-based Serious Organised Crime Agency.
Miss Spence was recruited by the SCDEA as a mole in light of her marriage to Albanian national Sokal Zefaj, the jury heard.
The revelations came during the trial of David Parker, 37, Paul Smith, 47, Philip Wade, 42, and Colin Coats, 42, who deny abducting and then torturing Miss Spence at a flat in West Kilbride, North Ayrshire, in April 2011.
It is claimed they murdered Miss Spence after torturing her to obtain financial information and then cut off her head and disposed of her body.
During cross-examination, Detective Sergeant Aileen Boyle, of Strathclyde Police, said there had been concern for Miss Spence's safety early on in their investigation. On further questioning by defence counsel Derek Ogg, QC, the officer claimed information suggested Miss Spence may have been married to Mr Zefaj, a businessman.
Mr Ogg said: "She was married to him and it was for this reason she was recruited by the SDCEA and the Serious Organised Crime Agency. Did you know this?"
The officer said she had not. Mr Ogg asked: "Would you agreed with me that would place Lynda Spence in very serious risk of her life if it was to be disclosed she was informing on an Albanian organised crime gang?"
The detective said: "If that was the case." The QC then said Miss Spence's SDCEA handler was contacted 48 hours after she went missing.
She was asked if, as a serving police officer, this would cause her concern and she agreed. The court was told that at the time she went missing Miss Spence was living in Glasgow with a Ukrainian woman who was a former lover of Mr Zefaj.
Mr Ogg asked: "Would you consider it safe for a confidential human intelligence source's identity to be known to the criminal underworld?" She replied: "No."
Solicitor General Lesley Thomson QC asked if anything pointed to an Albanian gang being involved in the alleged murder of Miss Spence and she replied: "Absolutely not."
The jury also heard that around April 2011 Miss Spence was being investigated by police in connection with a widespread fraud involving a large number of the Chinese community.
Miss Spence's best friend from school, Amanda Robertson, 29, told how, aged 19, she was asked to marry Miss Spence's boyfriend Mr Zefaj to allow him to stay in the UK. She was asked why Miss Spence hadn't just married him herself and replied: "She didn't want her parents knowing."
Miss Robertson divorced Mr Zefaj four years later and he and Miss Spence married.
Miss Robertson said she worked for a company, Fraser Properties, set up by Lynda Spence in Great Western Road, Glasgow, but left in 2010.
The jury was read a text Miss Robertson sent to a mutual friend referring to one of Miss Spence's emails.
It said: "She's got some deal involving Arabs and Albanians going on with peeps in New York. It's all a bit dodgy sounding."
Miss Robertson told the court she met murder accused Colin Coats with Miss Spence a number of times. The first time she met him she was in Miss Spence's car. She said Coats got in and handed over several thousand pounds in cash.
The trial continues.