Tesoro ( TSO) swung to a profit in the fourth quarter, driven by an improvement in refinery margins.

The San Antonio-based refiner reported quarterly profit of $97 million, or 70 cents pershare, compared with a loss of $40 million, or 29 cents per share, ayear earlier.

Tesoro's profit was $137 million, or 99 cents per share, afteraccounting for extraordinary charges. Analysts were expecting 91 centsper share, according to a survey by Thomson Reuters.

Tesoro's total revenue fell 34% last quarter to $4.33 billion,from $6.53 billion a year ago. Analysts were expecting $5.78 billion.

Tesoro overcame a sharp drop in consumer demand for refined petroleumproducts, boosting its refining margins 51% to $12.47 per barrelcompared with $8.28 per barrel a year ago.

"Margin realization improved as a result of our efforts to increasecrude flexibility and distillate production," Tesoro said in aprepared statement.

Shares of Tesoro were recently falling more than 8% at $14.82 per share.