Sandy Springs-based UPS will pay $40 million to resolve a federal investigation into its role in shipping drugs for illegal online pharmacies.

The company cooperated with the investigation and will not be prosecuted, according to the agreement with the the U.S. Attorney’s Office for the Northern District of California. UPS will also put in place a compliance program aimed at ensuring illegal online pharmacies do not use its services to distribute drugs.

UPS said it already has taken steps toward that aim.

Melinda Haag, U.S. Attorney for the Northern District of California, in a written statement said she hopes the UPS compliance program “will set the standard for the parcel delivery industry and will materially assist the federal government in its battle against illegal Internet pharmacies.”

FedEx is also being investigated, and said in a March 21 regulatory filing that it continues to “respond and cooperate.”

The growth of Internet pharmacies came as UPS has targeted the healthcare industry for growth, including pharmaceuticals.

Starting in 2003, UPS “was on notice” through some of its employees that Internet pharmacies were distributing controlled substances and prescription drugs that were not supported by valid prescriptions, according to the Justice Department.

UPS did not screen accounts to determine if online pharmacies were operating legally and have procedures to close accounts if warranted, according to the agency.

By 2005 one law enforcement task force in Virginia told UPS that its drivers were allowing suspect packages to be picked up in parking lots and beside highways. In some cases one customer was receiving drugs under several names, according documents issued with Friday’s agreement.

UPS began receiving grand jury subpoenas in the federal investigation starting in 2007.

The Drug Enforcement Administration, which handled the investigation, has targeted those who facilitate the illegal distribution of controlled substances. The Food and Drug Administration, which helped with the investigation, said the outcome will transform illegal Internet pharmacy shipping, “limiting the chances of potentially unapproved, counterfeit, or otherwise unsafe prescription medications from reading U.S.”

“We believe we have an obligation and responsibility to help curb the sale and shipment of drugs sold through illegal Internet pharmacies,” UPS said in a written statement.