A schooner rounds the corner of Portland Harbor near Bug Light in South Portland in July of 2019. Credit: Troy R. Bennett / BDN

SOUTH PORTLAND, Maine — A pipeline company has dropped a federal lawsuit against a Maine city, bringing an end to a yearslong legal battle over a local law that stopped the company from bringing crude oil from Canada.

South Portland and Portland Pipe Line Corp. were in court for more than six years over the city’s Clear Skies ordinance. The law stopped the pipeline company from reversing the flow of an old pipeline to bring the crude oil to Maine.

The company gave up its fight on Thursday, the Portland Press Herald reported. The company had wanted to bulk-load crude oil onto marine tank vessels in South Portland’s harbor. It has instead agreed with the 1st U.S. Circuit Court of Appeals to dismiss its appeal of a prior federal court judgment upholding the city’s ordinance.

South Portland Mayor Misha Pride said he is “proud of our community for having the fortitude to stand up for what we believed to be right, and to invest the time and financial resources necessary to defend ourselves.” The city has spent $2.8 million fighting the lawsuit, the Press Herald reported.

The city was buoyed last month by a brief filed by the Biden administration that supported its decision as constitutional. The city’s ordinance bans crude exports on the basis of protecting air quality.

The pipeline itself dates to the World War II era and is mostly out of commission in the modern era. It is more than 200 miles of underground pipeline and has carried billions of barrels of foreign crude from Maine to Montreal refineries over the years.