An official inquiry has been launched into how personal data has been collected and exploited in political campaigns such as Brexit and Donald Trump's presidential race.

It comes after it was revealed how data science firms such as Cambridge Analytica – which is backed by the US billionaire Robert Mercer – influenced millions of voters with targeted messages based on online activity.

The company openly talked about how it used Facebook and other social media sites to build detailed profiles of voters, but has denied any wrongdoing since details of an investigation were confirmed.

A spokeswoman for the Information Commissioner's Office (ICO) confirmed to the Guardian that an inquiry has been launched.

"We are conducting a wide assessment of the data-protection risks arising from the use of data analytics, including for political purposes, and will be contacting a range of organisations," the ICO spokeswoman said. "We intend to publicise our findings later this year."

She added: "We have concerns about Cambridge Analytica's reported use of personal data and we are in contact with the organisation."

The company – which has offices in London, New York and Washington – became involved with the Leave.EU campaign after Mercer recommended the company to former Ukip leader Nigel Farage.

Cambridge Analytica also played an instrumental role in the Trump campaign, after it switched over from supporting Ted Cruz.

Leave EU
The Information Commissioner's Office is investigating the Leave.EU campaign's use of Cambridge Analytica. Getty

Mercer, a part owner of the firm, also donated $13.5m (£10.98m) to Trump-linked super PACs and also funds the Breitbart News Network.

A spokesman for Cambridge Analytica denied it had played any role – either paid or unpaid – during the EU referendum campaign, something that would have to be declared to the Electoral Commission.

"We are in touch with the ICO, and are happy to demonstrate that we are completely compliant with UK and EU data law," the spokesman for Cambridge Analytica said.

They have also denied access to Facebook data and a spokesman for Facebook said: "Our investigation to date has not uncovered anything that suggests wrongdoing with respect to Cambridge Analytica's work on the Leave and Trump campaigns."

Academics have warned of how firms like Cambridge Analytica can play a dangerous role in politics if they go unchecked.

Dr Simon Moores, a Canterbury Christ Church University lecturer and a technology ambassador under Tony Blair's government, told the Guardian: "A rapid convergence in the data mining, algorithmic and granular analytics capabilities of companies like Cambridge Analytica and Facebook is creating powerful, unregulated and opaque 'intelligence platforms'.

"In turn, these can have enormous influence to affect what we learn, how we feel, and how we vote. The algorithms they may produce are frequently hidden from scrutiny and we see only the results of any insights they might choose to publish."