NEW YORK (CNNMoney) -- Google has agreed to a $500 million settlement with the U.S. Department of Justice for illegally allowing online Canadian pharmacies to advertise drugs to U.S. consumers.

The settlement, which represents the revenue received by Google for selling the ads through its AdWords program and the estimated revenue the Canadian pharmacies got from their sales to U.S. consumers, was one of the largest ever in the United States, according to the DOJ.







"This investigation is about the patently unsafe, unlawful importation of prescription drugs by Canadian online pharmacies, with Google's knowledge and assistance, into the United States, directly to U.S. consumers," said U.S. Attorney Peter Neronha.

Neronha said he hopes the settlement "gets the attention" of other potential violators as well, and he believes the settlement will limit the ability of "rogue online pharmacies" to sell drugs in the United States.

The Justice Department said Google (GOOG, Fortune 500) was aware as early as 2003 that Canadian pharmacies were illegally shipping prescription drugs into the United States. Google took steps to block pharmacies in countries other than Canada from advertising in the United States, but continued to allow Canadian pharmacy ads to target U.S. consumers.

Google eventually stopped the practice in 2009, once the company became aware of the U.S. Attorney's Office's investigation

"We banned the advertising of prescription drugs in the U.S. by Canadian pharmacies some time ago," a Google spokesman said in a prepared statement. "However, it's obvious with hindsight that we shouldn't have allowed these ads on Google in the first place."

The news of the pending settlement was first unveiled in a regulatory filing in May, catching many by surprise.

Google set aside the $500 million in the first quarter, revising its profit down for that period, which ended March 31, 2011. It said it earned $1.8 billion, or $5.51 per share, down from the $2.3 billion, or $7.04 per share, that it initially reported in April.

The search giant is no stranger to investigations by regulators from around the world.

The Federal Trade Commission formally notified Google in June that it is investigating the company. The company faces similar scrutiny in an ongoing antitrust investigation by the European Commission.

Also, the Department of Justice heavily scrutinized the company's purchase of flight data software company ITA, and the DOJ is currently studying Google's proposed $400 million purchase of digital advertising toolmaker Admeld.

Next up, regulators will analyze the company's proposed acquisition of Motorola Mobility (MMI).

The DOJ's probe of Google's AdWords sales had its origins in an entirely separate investigation.

The agency said it was initially looking into a financial fraud case, the main target of which fled Mexico. While a fugitive, he began to use Google's AdWords to advertise the illegal drug sales. After being apprehended in Mexico and returned to the United States, he began cooperating with law enforcement agents and provided information about his use of Google ads.

That prompted investigators to set up a sting, creating undercover websites for the purpose of advertising illegal prescription drug sales through AdWords.