Following the closure of the South Philadelphia refining complex, a major gasoline pipeline has reached an agreement to give Midwestern refiners greater access to Pennsylvania markets.

Buckeye Partners LP, which is based in Houston, has reached an agreement to allow Midwestern refiners to ship more fuel farther into Pennsylvania on its Laurel pipeline, a 350-mile cross-state pipeline that historically was used by Philadelphia refineries to transport motor fuel and heating oil across Pennsylvania.

Buckeye reached a settlement with refiners, large Western Pennsylvania retailers such as Sheetz and Giant Eagle, and state regulators to allow the Laurel pipeline to sell some of its capacity to fuel producers in Ohio, Illinois, and Michigan to send fuels as far as Altoona. The agreement was filed Wednesday, but posted publicly Thursday.

The agreement to allow the Laurel pipeline to flow in either direction between Pittsburgh and Altoona settles a three-year battle that had been fiercely fought before the Pennsylvania Public Utility Commission (PUC) and the Federal Energy Regulatory Commission (FERC). Petroleum pipelines are like toll highways, and the shipping rates and rules of access are fixed by regulators.

The pipeline’s current shippers and customers had argued to keep the pipeline flowing exclusively one-way from east to west, at least as far as Pittsburgh, effectively preserving the capacity for Philadelphia and New Jersey refiners, as well as importers with fuel terminals on the Eastern seaboard.

But Midwestern producers, who have increased fuel output in recent years and are pushing to expand markets, had pressed Buckeye to allot some of its underused pipeline to eastbound fuel, effectively taking market share away from coastal producers.

Under the settlement, east-to-west shippers would be guaranteed access to the pipeline at least through the end of 2024, after which Buckeye could seek to switch the flow completely from west to east as far as Altoona. Both sides have argued that consumers would be harmed if the decision went the wrong way.

Decisions by Pennsylvania and federal regulators had not gone in Buckeye Partners’ favor, and its appeal before the Commonwealth Court was scheduled to be argued in September. If the PUC and FERC agree to the settlement, the court case would be dropped.

Though the parties had been talking for months, the pipeline settlement may have been accelerated by the Philadelphia Energy Solutions’ recent decision to close its 335,000-barrel-a-day refining complex in South Philadelphia after a June 21 fire. PES, which has filed for bankruptcy and is looking for a buyer, represents 25 percent of the refining capacity in the Northeast and is a major shipper on the Laurel pipeline.

The settlement provides that if shipments from PES or a successor company fall off after 2022, then the agreement will no longer apply and Buckeye can seek to use the pipeline exclusively to transport Midwestern fuels into central Pennsylvania.

“We are pleased to reach this agreement that settles nearly three years of proceedings aimed at ensuring Pennsylvania consumers, shippers, and retailers enjoy reliable access to fuels on the Laurel pipeline," Buckeye said in a statement. "This forward-looking settlement, subject to regulatory approvals, will provide Pennsylvania consumers with greater access to more affordable, American-made fuels from the Midwest while maintaining westbound service.”