Sunoco Inc. (SUN) swung to a first-quarter profit as its refining and supply business benefitted from lower expenses.

The company's core refining and supply business swung to a profit of $23 million from a year-ago loss of $123 million, due to lower oil costs and higher realized margins, which was partially offset by lower production volumes. Profit at its retail operations slumped 77% to $6 million.

Despite its profits in the quarter, Sunoco remains braced for a difficult market for its refined products and chemicals, and is going forward with cost-cutting measures.

"We continue to expect a challenging market for petroleum and chemical products due to ongoing economic weakness and additional global supply," said Chief Executive Lynn Elsenhans.

Sunoco retained consultancy McKinsey & Co. and undertook an internal effort to reduce spending in mid-2008, following Elsenhans' appointment.

Sunoco's first-quarter results reflect cost-cutting measures undertaken in the first phase of its business improvement initiative. The company said it plans to cut spending by more than $300 million on an annualized basis by year-end.

Sunoco, the second-largest U.S. independent oil refiner by volume after Valero Energy Corp. (VLO), reported a profit of $51 million, or 10 cents a share, compared with a year-earlier loss of $38 million, or 50 cents a share. Excluding items, earnings would have been 50 cents a share.

Revenue decreased 50% to $6.44 billion.

Analysts had expected per-share earnings, excluding items, of 34 cents. Sunoco's earnings beat was largely due to its refining performance, industry analysts said.

"Sunoco had better performance in refining operations largely attributable to better cost control," said Ann Kohler, an analyst with New York investment bank Caris & Co.

The company geared its refineries to run the cheapest crude possible, and tried to produce the most profitable slate of products during the quarter, said Thomas Golembeski, a Sunoco spokesman.

Sunoco's shares rose 1.1% to $31.79 in after-hours trading.

-By Jessica Resnick-Ault, Dow Jones Newswires; 201-938-4435; jessica.resnick-ault@dowjones.com

(John Kell contributed to this article.)