Six years ago, Portland was the second-busiest oil port on the East Coast, handling nearly 150 million barrels of crude oil annually. So far this year, no crude oil has moved through the harbor.

The inactivity has led to news reports that the Portland-Montreal Pipe Line has shut down and is being taken out of service. One account said the line, which for 75 years has moved crude oil from overseas across northern New England to refineries in Montreal, had been “mothballed.”

The company that owns the line, however, is disputing that characterization.

“Portland-Montreal Pipe Line remains open for business, supporting its customers, employees and annuitants, continuing the safe and excellent operation it has long been known for,” according to Jim Merrill, a spokesman for the owners.

But being open for business and conducting business are two different things. Whether the pipeline will ever again move large volumes of oil may hinge on a legal challenge in the United States and a competing pipeline proposal in Canada, which has enormous oil reserves that are essentially landlocked. Neither of these factors appears close to being resolved this year.

The company currently is fighting the city in federal court over a 2014 ordinance that bans the export of crude oil. The ordinance could have fatal consequences for the pipeline. While the company says it has no plans now, it’s possible that the only way it can survive is to move crude oil from western Canada east for overseas export, a reversal of what it was designed for.

The lawsuit has attracted international attention. Environmental activists say developing the heavy oil deposits in western Canada are more apt to cause a spill and will have an outsized effect on global climate change. They’ve been working to derail any pipeline proposal aimed at exporting the fuel overseas.

At the same time, the company has been a valued employer with a good safety record that until a few years ago spent $3.5 million a year in the area economy. It still owns 11 parcels of land and a waterfront terminal valued at $42 million. It’s South Portland’s fifth-largest taxpayer, contributing $747,000 a year to the budget.

The facility was built during World War II to get oil to Montreal refineries, which were iced in during the winter. It was upgraded over time to feature two separate pipes running underground for 236 miles from South Portland. Together, they could handle 600,000 barrels of oil a day. Tank farms in South Portland also hold 3.5 million barrels.

But in recent years, competition and consolidation shut five of six Montreal refineries. That began a steady decline for the Portland pipeline. As demand fell, the company took an older, 18-inch-diameter pipeline out of service. It has been using a newer, 24-inch line, which has been operating well below capacity.

Contributing to the decline is the changing business practices of the last Montreal refinery, owned by Suncor Energy, which has a 23 percent ownership interest in the pipeline. Suncor also is a major developer of deposits in Alberta known as oil sands and has made a transition from overseas crude oil to supplies from western Canada and North Dakota. That shift was finalized late last year, when the east-west flow of crude was reversed in a pipeline that runs across Ontario to Montreal, known as Line 9. The line also helps supply the only other operating Quebec refinery, Valero Energy Corp. near Quebec City.

Environmental activists in Canada tried but failed to stop Line 9. Now the battle in Canada to keep oil sands in the ground has shifted to a bigger pipeline that, if built, could seal the fate of Portland’s operation.

TransCanada Corp. wants to build the Energy East pipeline, which would run more than 2,700 miles and connect the Alberta oil fields with the Irving Oil refinery in Saint John, New Brunswick. It would bypass Maine north of Aroostook County and give Canada and its struggling oil industry a clear path to export markets, without crossing an international border.

The line could carry more than 1 million barrels of oil a day in 2020, by converting an existing natural gas pipeline to oil and building a new section across Quebec and New Brunswick. Provincial hearings on the $11 billion (U.S.) project began earlier this month in Quebec, a prelude to a review by Canada’s National Energy Board later this year.

The Energy East pipeline is shaping up to be a national tussle on the scale of the failed Keystone XL proposal in the United States, according to Pierre-Oliver Pineau, a professor and energy expert at the HEC Montreal business school. Both of them share common dynamics.

Keystone XL would have given Canada an overseas export route, by connecting the Alberta oil fields with America’s Gulf Coast terminals. It was supported by the oil industry and Republican politicians, and opposed by environmental groups and most Democrats. After five years of wrangling, Keystone XL was rejected last fall by President Obama, who said it was unneeded and would worsen climate change.

‘HE HAS TO FIND A BALANCE’

Canada’s new prime minister, Justin Trudeau, finds himself in a similar position. Young and charismatic, from a political district in Quebec, he last year replaced Stephen Harper, who led Canada for a decade and once worked for the petroleum industry in Alberta. Trudeau has signaled that climate change matters to him. At the same time, he’s trying to play down the east-west rivalry that’s being fanned by the pipeline proposal, stating this month at an energy conference that “we need both pipelines and wind turbines” in Canada.

“It’s very hard to find a national strategy,” Pineau said. “Opposing the pipeline would hurt him in the west. He has to find a balance.”

Pineau said that the fight over Keystone XL has convinced Canada’s oil industry that it’s too risky to attempt to reverse the flow on the Portland pipeline. That’s why Energy East seemed like a better strategy, despite its distance and cost. But the decision was a nod to politics, not economics, Pineau said.

“From a purely economic perspective, it makes more sense to use the current infrastructure,” Pineau said. “The Portland pipeline is already built and has been used for many years without a major accident.”

The idea of reversing the flow of an oil pipeline isn’t a new one, and Line 9 is a case in point.

From 1976 to 1999, Line 9 moved crude from western Canada to Montreal. When imports became cheaper, the line’s flow was reversed, which greatly benefited the Portland-Montreal Pipe Line. Recently, domestic oil has become cheaper again, so Enbridge, which owns the line, changed the flow back to eastbound service.

Similar examples are at play in the United States.

America’s shale oil boom led the owners of the Seaway pipeline to start pumping from Oklahoma to Houston, Texas, in 2012. The line was originally built for a south-to-north flow. Owners of the Capline, which was built to carry oil from Louisiana to Illinois, are now looking at flipping the flow. As with the Portland-Montreal line, both lines became unprofitable as oil markets changed.

ENERGY ALTERNATIVES?

It’s not just the source of oil that leads to pipeline reversals, but the shifting price, according to John Auers, executive vice president at the Turner, Mason & Co. petroleum consulting firm in Dallas.

Oil pumped from Texas and the Midwest is priced differently than oil imported from Europe, for instance. Auers, who is familiar with the Portland pipeline, noted that the “spread” – the price advantage that North American oil had over imported oil – has narrowed recently. That could lead Suncor to order some overseas deliveries via the Portland pipeline, he said, if the price is right.

“It’s always good to have more than one option,” he said. “They don’t want to be tied to receiving crude from just one direction. It could make sense to move some barrels up that pipeline.”

Both Merrill, the spokesman for the Portland pipeline, and a media representative of Suncor, were asked if such deliveries seemed likely this year. Neither replied to the question, although Merrill cited the lawsuit and said the company wouldn’t comment further on its operations.

Although South Portland and the pipeline owners are at odds over crude exports, the city remains interested in the company’s viability, according to Jim Gailey, the city manager.

“The city isn’t against working with the pipeline on diversifying their operations and moving their business model to other alternatives in the energy world,” he said.

Asked what those alternatives might be, Gailey mentioned using some of their land for solar farms. He also noted that one of the two underground pipelines had once been converted to carry natural gas.

That gas conversion took place in the 1980s. When Line 9 was first built and imported oil prices surged in the late 1970s, tanker traffic to South Portland fell off. So the company was able to use its assets to find new revenue, when the smaller of the two pipes was converted to move natural gas from Canada. When market conditions for imported oil improved, the line was switched back to oil.

But today’s natural gas fundamentals are different. Two dedicated natural gas lines from Canada were built across Maine in the 1990s. One of them, the Portland Gas Natural Transmission System, runs near the oil pipeline route until Westbrook, where it connects to a regional corridor that can carry low-priced natural gas from Pennsylvania. Also, carrying natural gas through an oil pipeline would offer no use for the company’s tank farms and waterfront terminal.

For these and other reasons, the future of the Portland-Montreal Pipe Line appears tied to moving liquid petroleum. One way or the other.