Google will pay $500 million to the U.S. Department of Justice for allowing Canadian-based pharmacies to advertise prescription drugs to Internet users in the United States. Prior to 2009, Google allegedly allowed Canadian pharmacies to purchase AdWords ads for pharmaceutical items that were viewable by American consumers.

The company was aware as early as 2003 that the shipment of prescription drugs from Canada to the United States violated the Food, Drug and Cosmetic Act and the Controlled Substances Act, the DOJ said. While the company took steps to block online pharmacies in countries other than Canada from advertising in the United States, Google permitted Canadian pharmacies to continue, the agency alleged, and was aware that American consumers were purchasing drugs from the Canadian pharmacies.

According to the DOJ, Google even provided customer support to some of the Canadian pharmacies between 2003 and 2009, by providing assistance in placing and optimizing their AdWords advertisements.

Furthermore, Google was allegedly on notice that the Canadian pharmacies sold prescription drugs based on an “online consultation” rather than a valid prescription.

“This settlement ensures that Google will reform its improper advertising practices with regard to these pharmacies while paying one of the largest financial forfeiture penalties in history,” Deputy Attorney General James F. Cole said in a statement about the case.

The payment represents a forfeiture of Google’s gross revenue from the online Canadian pharmacies that used the program and the revenue from sales those pharmacies made to U.S. residents.

Google acknowledged that it improperly assisted Canadian online pharmacy advertisers targeting those in the United States and accepted responsibility for its conduct, according to the DOJ. The company is also subject to compliance and reporting requirements.

To read the DOJ’s statement on the Google case, click here.

Why it matters: The DOJ said the Google investigation began after the agency apprehended a fugitive who had used the AdWords program to advertise drugs for sale while hiding in Mexico. After the fugitive began cooperating with law enforcement, the agency established its own undercover Web sites in order to advertise drugs using the AdWords program. Despite the settlement, Google’s legal woes aren’t over – one week after the settlement was announced, an investor filed a federal lawsuit against the company and its directors, alleging the defendants breached their fiduciary duty to shareholders by facilitating the illegal import of prescription drugs into the country through the AdWords program.