Sunoco announced the move Thursday as it reported a net loss of $660 million before taxes for the fourth quarter.

It also gave details about its exit from the refining business, saying it will create a $250 million insurance fund to handle environmental problems at the refineries.

The Philadelphia company said it will also buy back up to 19.9 percent of its stock, raise its quarterly dividend by 33 percent, and repurchase up to $400 million in debt.

It also plans to make an $80 million contribution to its pension fund to defer any additional contributions "for the foreseeable future," and to eliminate future retiree medical costs by contributing $200 million to a special trust fund.

Sunoco's shares, which fell 15 cents in regular trading to $38.25, gained 91 cents, or 2.4 percent, to $39.16 in extended trading after the news.

Elsenhans said on a conference call with investors that she told the board, "I was no longer the right person to lead Sunoco."

She became the company's first female CEO in 2008, coming from Royal Dutch Shell PLC. Sunoco noted that during her tenure she oversaw the sale of its heating oil and chemical businesses, the spin-off of SunCoke Energy, and the exit of the refining business, representing two-thirds of Sunoco's assets.

The outgoing CEO will remain chairman until the annual shareholder meeting in May, when MacDonald, 46, will also assume that title.

Weak demand for gasoline and a glut of refining capacity has meant low profit margins for refiners. Sunoco also has to pay more for some of its supply of crude oil than rivals such as Marathon Petroleum Corp., which have refineries in the middle of the country and get cheaper, West Texas Intermediate crude.

Sunoco has been trying to sell its Philadelphia and Marcus Hook, Pa., refineries and has contacted about 150 potential buyers, from oil companies to private equity firms, Elsenhans said. She said there was some interest in the Philadelphia refinery, but that if it can't be sold, it will be idled by July. The Marcus Hook refinery is already being powered down.

Sunoco said the $660 million fourth-quarter loss before taxes compared with a pretax gain of $119 million a year earlier.

Excluding special items, the company said it would have a pretax loss of $48 million.

The company said the figures were preliminary and income tax amounts were not yet final.

It expects to report full results after taxes next week.

The logistics and retail businesses that the company plans to keep had pretax income of $106 million, while refining and supply had a pretax loss of $117 million.