Two former employees of Twitter have been charged with spying on behalf of Saudi Arabia, with prosecutors alleging they used their positions to dig up personal information about critics of the kingdom.

A third person, who was not employed by Twitter but who allegedly acted as an intermediary, was also charged with spying in documents unsealed in San Francisco, where the social media giant has its headquarters.

The 26-page indictment alleges that Ahmad Abouammo, who left his job as the media partnership manager responsible for Twitter’s Middle East region in 2015, was part of a coordinated effort launched by Riyadh to look into the private data of thousands of Twitter accounts.

Among those accessed was the account of a popular journalist, Omar Abdulaziz, who subsequently became a friend of Jamal Khashoggi, a journalist and columnist who was killed last year in a Saudi consulate in Istanbul, allegedly by Saudi agents.

A second former Twitter employee, Ali Alzabarah, was also charged with spying, as was a third man, Ahmed Almutairi. Mr Abouammo is a US citizen, the other two are citizens of Saudi Arabia, according to the charging document unsealed on Wednesday.

Khashoggi disappearance: Forensic police investigate Saudi consul Show all 12 1 /12 Khashoggi disappearance: Forensic police investigate Saudi consul Khashoggi disappearance: Forensic police investigate Saudi consul According to local media reports, Saudi consul Mohammad al-Otaibi left Turkey on 16 October. A Turkish prosecutor on 15 October has entered the Saudi consulate in Istanbul to investigate the disappearance of dissident Saudi journalist Jamal Khashoggi, an inspection that was being carried out jointly with a Saudi team AFP/Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul Turkish forensic police officers work on the roof of the residence of the Saudi consul in Istanbul EPA Khashoggi disappearance: Forensic police investigate Saudi consul Khashoggi went missing on 2 October when he entered the Saudi consulate to pick up paperwork AP Khashoggi disappearance: Forensic police investigate Saudi consul ISTANBUL, TURKEY - OCTOBER 17: Turkish police arrive to investigate the Saudi Arabian consulate general residence as investigations continue into the disappearance of journalist Jamal Khashoggi on October 17, 2018 in Istanbul, Turkey. Turkish police first entered and searched the Saudi Arabian consulate on October 15 amid a growing international backlash about the disappearance. Khashoggi, a U.S. resident and critic of the Saudi regime, has been missing since visiting the Saudi Arabian consulate on October 2. Turkish officials have said they believe he was killed inside. (Photo by Chris McGrath/Getty Images) ***BESTPIX*** Chris McGrath Khashoggi disappearance: Forensic police investigate Saudi consul Turkish forensic and investigation officers arrive at Saudi Consul's residence on October 17, 2018 in Istanbul. - Saudi Arabia's consul to Istanbul Mohammed al-Otaibion on October 16, 2018 left the Turkish city bound for Riyadh on a scheduled flight, reports said, as Turkey prepared to search his residence in the probe into the disappearance of journalist Jamal Khashoggi. (Photo by OZAN KOSE / AFP)OZAN KOSE/AFP/Getty Images OZAN KOSE AFP/Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul Turkish police arrive to investigate the Saudi Arabian consulate general residence Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul Turkish forensic police search for evidence at the garden of the Saudi Arabia's Consul General Mohammad al-Otaibi AFP/Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul Turkish police search the rooftop of the Saudi Arabian consulate general residence Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul Turkish police arrive at the residence of the Saudi consul General Mohammed al-Otaibi to conduct a search AP Khashoggi disappearance: Forensic police investigate Saudi consul Turkish police officers gather as they prepare to enter Saudi Arabia consul's residence, in Istanbul, Wednesday, Oct. 17, 2018. America's top diplomat is in Turkey, where a strongly pro-government newspaper has published a gruesome recounting of the alleged slaying of Saudi writer Jamal Khashoggi at the Saudi Consulate in Istanbul. (AP Photo/Petros Giannakouris) Petros Giannakouris AP Khashoggi disappearance: Forensic police investigate Saudi consul Turkish forensic police search for evidence at the garden of the Saudi Arabia's Consul General Mohammad al-Otaibi AFP/Getty Images Khashoggi disappearance: Forensic police investigate Saudi consul ISTANBUL, TURKEY - OCTOBER 17: Turkish police search the rooftop of the Saudi Arabian consulate general residence as investigations continue into the disappearance of journalist Jamal Khashoggi on October 17, 2018 in Istanbul, Turkey. Turkish police first entered and searched the Saudi Arabian consulate on October 15 amid a growing international backlash about the disappearance. Khashoggi, a U.S. resident and critic of the Saudi regime, has been missing since visiting the Saudi Arabian consulate on October 2. Turkish officials have said they believe he was killed inside. (Photo by Chris McGrath/Getty Images) Chris McGrath Getty Images

It alleged that Mr Almutairi at one time ran a social media marketing company that did work for the Saudi royal family.

The document claims the two former employees were rewarded with a designer watch, and tens of thousands of dollars funnelled into secret bank accounts. They were charged with acting as agents of Saudi Arabia without registering with the US government.

The Saudi government had no immediate comment through its embassy in Washington.

The Associated Press said Mr Abouammo, was also charged with falsifying documents and making false statements when questioned by FBI agents at his Seattle home. The offences carry a maximum penalty of 30 years in prison if convicted.

Investigation finds evidence of Saudi double-tap strikes in Yemen

At his appearance in Seattle federal court on Wednesday, Mr Abouammo was ordered to remain in custody pending a detention hearing set for Friday.

His lawyer, Christopher Black, declined to comment, as did Mr Abouammo’s wife, who did not give her name.

Prosecutors claimed Mr Alzabarah was recruited by flying him to Washington DC, for a private meeting with an unnamed member of the Saudi royal family.

“Within one week of returning to San Francisco, Alzabarah began to access without authorization private data of Twitter users en masse,” the complaint said.

The effort included the user data of over 6,000 Twitter users, including at least 33 usernames for which Saudi Arabian law enforcement had submitted emergency disclosure requests to Twitter, investigators said.

After being confronted by his supervisors at Twitter, Mr Alzabarah acknowledged accessing user data and said he did it out of curiosity, authorities said.

It is said Mr Alzabarah was placed on administrative leave, his work-owned laptop was seized, and he was escorted out of the office. The next day, he flew to Saudi Arabia with his wife and daughter and has not returned. Commentators pointed out that the case is of particular interest because it targets a supposed major ally whose crown prince, Mohammed bin Salman, has developed a warm relationship with Donald Trump.

“The criminal complaint unsealed today alleges that Saudi agents mined Twitter’s internal systems for personal information about known Saudi critics and thousands of other Twitter users,” said US attorney David Anderson. “We will not allow US companies or US technology to become tools of foreign repression in violation of US law.”

The FBI began monitoring Twitter employees as far back as 2014, according to the charging document. It informed senior executives at the end of the following year to allege the Saudi government was grooming employees.