Google has come under attack for violating users' privacy and ignoring their wishes after admitting that it intentionally circumvented security settings in Apple's Safari browser to track users on both desktop computers and iPhones.

A number of other advertisers exploited the loophole it had created to track those users too.

"Our data suggests that millions of users may have been affected," Jonathan Mayer, the independent researcher at Stanford University who discovered the workaround by the search giant, told the Guardian.

An Apple spokesman said: "We are aware that some third parties are circumventing Safari's privacy features and we are working to put a stop to it."

The Electronic Frontier Foundation (EFF), a pressure group for users' rights online, said that then admission was bad news for the company, coming so soon after the news that it is aiming to unite the data it keeps about people using different parts of its services such as YouTube and its main search engine.

"It's time for Google to acknowledge that it can do a better job of respecting the privacy of web users," the EFF said in a statement, in which it warned: "Google, the time has finally come. You need to make a pro-privacy offering to restore your user's trust … it's time for a new chapter in Google's policy regarding privacy. It's time to commit to giving users a voice about tracking and then respecting those wishes."

The company may also be tracking people without their knowledge on other browsers, including those on its own Android phones, because those do not implement the same security restrictions as Apple does.

The admission will put extra pressure on the company in the US where it has already fallen foul of the US Federal Trade Commission over privacy practices, and in Europe where it could still be subject to an antitrust investigation by the European Commission.

The circumvention, carried out by a small piece of code, meant that people could see messages indicating whether their associates in Google "Circles" on its Google+ social network had clicked on ads – but it also let Google and other advertisers see which websites people landed on.

Mayer told the Guardian that his team had been looking into what was being done for two months, and was sure it had been used by Google certainly since December – though it could have been running since July 2011.

Google declined to answer a Guardian request to say when it had begun the tracking.

The search giant insisted that a report in the Wall Street Journal, which first revealed the tracking, mischaracterised its actions, and that the users' identities had remained anonymous throughout – although they were signed in to Google's systems.

At least three other advertising companies – Vibrant Media, WPP Plc's Media Innovation Group and Gannett's PointRoll – also exploited the Google code to track users.

Google's search engine is the default on all Apple's mobile devices and in its Safari browser, of which there are more than 100m in use.

By default, Apple's Safari browser only accepts cookies – small chunks of text with unique information such as the time of a user's visit to a site – which come directly from by the sites that users are browsing.

But Google wanted to use its DoubleClick and other ad systems to track where people go online, so that it can serve "relevant" ads. It also wanted to be able to integrate its Google+ data into that information.

To get around Safari's blocking, the Wall Street Journal explains, Google put code onto some of its ads served by DoubleClick's servers at doubleclick.net to fool the Safari browser into thinking the user was interacting with DoubleClick.

But, the EFF notes: "That had the side effect of completely undoing all of Safari's protections against doubleclick.net."

That meant that other DoubleClick cookies, including the principal tracking one which Safari would normally block, were allowed.

"Like a balloon popped with a pinprick, all of Safari's protections against DoubleClick were gone," the EFF said.

In a statement, Google said: "We used known Safari functionality to provide features that signed-in Google users had enabled. It's important to stress that these advertising cookies do not collect personal information.

"Unlike other major browsers, Apple's Safari browser blocks third-party cookies by default. However, Safari enables many web features for its users that rely on third parties and third-party cookies, such as [Facebook's] 'Like' buttons.

"Last year, we began using this functionality to enable features for signed-in Google users on Safari who had opted to see personalised ads and other content – such as the ability to '+1' [the equivalent of Facebook's 'Like' for Google's new Google+ social network] things that interest them.

"To enable these features, we created a temporary communication link between Safari browsers and Google's servers, so that we could ascertain whether Safari users were also signed into Google, and had opted for this type of personalisation.

"But we designed this so that the information passing between the user's Safari browser and Google's servers was anonymous – effectively creating a barrier between their personal information and the web content they browse.

"However, the Safari browser contained functionality that then enabled other Google advertising cookies to be set on the browser [by other advertising companies using the DoubleClick network]. We didn't anticipate that this would happen, and we have now started removing these advertising cookies from Safari browsers. It's important to stress that, just as on other browsers, these advertising cookies do not collect personal information."

While the data collected by the cookies would not contain the user's name or personal details, privacy campaigners have long pointed out that the pattern of a user's web browsing allows a picture of them to be built up which can led to direct identification or profiling so precise that it leave little doubt about their identity.

Google's use of such systems in defiance of the settings of the user's browser is the first time the company has been found doing so.

Google said: "Users of Internet Explorer, Firefox and Chrome were not affected. Nor were users of any browser (including Safari) who have opted out of our interest-based advertising program using Google's Ads Preferences Manager.

"We didn't anticipate that this would happen, and we have now started removing these advertising cookies from Safari browsers."

Cory Doctorow, a novelist and columnist for the Guardian, commented at the Boing Boing blog that he believed the tactic by Google indicated that the internal pressure put on staff by chief executive Larry Page to integrated "social" elements into all its work – which has included the announcement that all staff bonuses are now tied to Google's success in social software – "is leading the company to take steps to integrate G+ at the expense of the quality of its other services.

He pointed out that his own Google Mail account, whose address he has never made public, "has somehow become visible to G+ users, so that I get many, many G+ updates and invites to this theoretically private address, every day, despite never having opted into a directory and never having joined G+".