Ford Motor Co. says it posted a surprise second-quarter profit of $2.3 billion due mainly to a huge gain for debt reduction.

The profit is a vast improvement from the record $8.7 billion loss that Ford reported in the same quarter last year.

The Dearborn, Mich.-based automaker says it earned 69 cents per share, compared with a $3.88 per share loss for the same quarter in 2008. That was the worst quarter in company history.

But the latest profit comes because of a $3.4 billion gain due to debt reduction. In March Ford swapped stock and cash to reduce its loan and bond debt by $7.7 billion.

Without special items, Ford would have lost $424 million, or 21 cents per share. Analysts surveyed by Thomson Reuters expected a per share loss of 50 cents.