Princess Cruise Lines will pay a $40 million penalty after pleading guilty to seven federal charges in an illegal ocean pollution case that involved one ship's use of a so-called magic pipe to divert oily waste into the waters, authorities said Thursday.

Miami U.S. Attorney Wifredo Ferrer told a news conference the penalty is the largest ever of its kind. A plea agreement filed in federal court also requires Carnival Corp., parent company of the Princess line, to submit 78 cruise ships across its eight brands to a five-year environmental compliance program overseen by a judge.

The cruise ship Crown Princess travels into Port Canaveral, Florida in this July 18, 2006. JOE SKIPPER / Reuters

Ferrer said the illegal practices came to light when an engineer aboard the Caribbean Princess discovered the "magic pipe" in 2013 off the coast of Great Britain and told investigators about it. Authorities later learned the 952-foot ship had been illegally discharging oily water into the ocean since 2005.

"Our open seas are not dumping grounds for waste," Ferrer said. "One thing we must never do is take our clear blue oceans for granted."

A single illegal discharge dumped 4,227 gallons of oil-contaminated waste about 20 miles off the coast of England on Aug. 26, 2013, according to court documents.

The documents also show illegal practices were found on four other Princess ships, including use of clean ocean water to fool onboard sensors that would otherwise detect dumping of improperly contaminated bilge water. Authorities say cost savings was the motive and that the ship's officers and crew conspired to cover up what was going on.

Related: Cruise Ship Passenger Goes Overboard Near Bahamas

John Cruden, assistant attorney general for the Justice Department's environmental division, said the Caribbean Princess "violated the law, they covered it up and then they lied about it."

"We're sending a strong message in this case to the entire industry."

In a statement, Princess said it was "extremely disappointed" that employees had violated company policy and federal law regarding discharge of pollutants. The cruise line said it cooperated with investigators after the magic pipe was unveiled in 2013 and has taken numerous steps to fix the problem.

"Although we had policies and procedures in place, it became apparent they were not fully effective," the statement said. "We are very sorry that this happened and have taken additional steps to ensure we meet or exceed all environmental requirements."

The oily bilge waste comes from a ship's engines and fuel systems. Instead of being dumped raw into the ocean, it is supposed to be offloaded when a ship is in port and either burned in an incinerator or taken to a waste facility. Sometimes bilge water can be discharged into the ocean but only after almost all oil is separated out.

The plea agreement and penalty must be approved by a Miami federal judge. If it is, $14 million of the Princess penalty will be earmarked for environmental projects in Florida, Great Britain and in international open waters.

The 17-ship Princess line is based in Santa Clarita, California. Its parent company, Carnival, is based in Miami and is the largest cruise ship operator in the world.