Maine’s attorney general and the Federal Trade Commission have stepped in to stop Irving Oil Terminals from buying ExxonMobil’s petroleum terminals in South Portland and Bangor, along with the 124-mile pipeline that connects them.

Completion of the purchase, which was announced in November 2009, would have violated merger laws and reduced competition, state and federal officials said.

“Promoting competition in an industry where consumer impact is high is critical, particularly in these times of rising fuel and gasoline prices,” Schneider said in a written statement. “The people of Maine, particularly the Bangor and Penobscot Bay area, will benefit by keeping the gasoline marketplace open.”

Under the settlement, Irving gives up its rights to buy the Bangor terminal, the pipeline and 50 percent of the South Portland terminal to Buckeye Partners L.P. and Buckeye Pipe Line Holdings.

The settlement is still subject to final FTC and court approvals.