UPS Friday agreed to forfeit $40 million and implement a compliance program after a Department of Justice probe found the company delivered drugs on behalf of illegal online pharmacies.

The agreement followed an investigation that showed that UPS was shipping drugs on behalf of Internet pharmacies that were distributing controlled substances and prescription drugs that were not supported by a valid prescription.

Despite being on notice from employees that such illegal shipments were being delivered, UPS "did not implement procedures to close the shipping accounts of Internet pharmacies," said a Department of Justice statement.

"We are pleased with the steps UPS has taken to stop the use of shipping services by illegal on-line pharmacies," said US Attorney Melinda Haag in the statement.

"We are hopeful that the leadership displayed by UPS through the compliance program will set the standard for the parcel delivery industry," she said.

UPS officials weighed whether to target online pharmacies as a business in the mid-2000s and continued to accept their business even after they were flagged as problematic or illegal, according to an agreed statement of facts released by the Justice Department.

UPS spokeswoman Susan Rosenberg said the company has cooperated fully with the investigation, which dates to 2007.

"As an industry leader, UPS is taking responsibility and playing a role to address the issue of illegal online pharmacies," Rosenberg said.

The Department of Justice has also launched an investigation into UPS rival FedEx.

FedEx said in March 21 securities filing that it responded to grand jury subpoenas and continues to "cooperate with the investigation."

"We do not believe that we have engaged in any illegal activities and will vigorously defend ourselves in any action that may result from the investigation," FedEx said in the filing.

A FedEx spokesman could not be immediately reached Friday for comment.

[Package delivery person via Shutterstock]