Jamal Khashoggi was working to expose Saudi Arabia's use of social media trolls before he was murdered, one of his friends has revealed.

The writer, who disappeared after entering the Saudi consulate in Istanbul on October 2, had also fallen victim to online harassment, according to a fellow Saudi dissident.

Omar Abdelaziz, who now lives in Canada, told Euronews he and Khashoggi had been working on a series of projects together, including an exposé of the use of social media by pro-government accounts.

Jamal Khashoggi (pictured) was working to expose Saudi Arabia's use of social media trolls before he was murdered, one of his friends has revealed

He told the website, that his friend had been targetted on Twitter by so-called 'electronic flies' as they worked together on human rights campaigns.

He said: 'I have known (Khashoggi) for three years but I did not agree with him politically because he seemed closer to the official approach.

'But things changed since Khashoggi left Saudi Arabia in September 2017. We reviewed this relationship and we got in touch almost every day.'

On Saturday, the New York Times reported that Saudi Arabia deployed an online army to harass Khashoggi and other critics of the kingdom on Twitter.

The efforts to attack Khashoggi and other influential Saudis, and sway public opinion against them on the social media service, included a so-called troll farm based in Riyadh and a suspected spy within Twitter that the kingdom utilised to monitor user accounts, the New York Times reported.

Twitter declined to comment. A representative from the Saudi embassy in Washington did not immediately respond to a request for comment.

The writer, who disappeared after entering the Saudi consulate in Istanbul on October 2 (pictured), had also fallen victim to online harassment, according to a fellow Saudi dissident

Saudi officials said on Saturday that Washington Post columnist Khashoggi died in a fight in its Istanbul consulate. But Turkish officials say Khashoggi was assassinated and dismembered by Saudi security forces.

The Times reported Saudi operatives began a social media campaign to harass critics in 2010.

Saud al-Qahtani, an adviser to Crown Prince Mohammed bin Salman, created the strategy behind the effort, the newspaper said, citing U.S. and Saudi officials.

Qahtani was one of five officials Saudi King Salman has fired, according to Saudi state media, following the global controversy over Khashoggi's disappearance.