NEW YORK (CNNMoney.com) -- Ford Motor Co. reported a net profit in the second quarter thanks to efforts to reduce its debt. But the company posted another operating loss during the second quarter due to a continued slump in sales.

Still, that loss was much smaller than a year ago and Wall Street's forecasts.

The company converted much of its debt to equity during the period through an offer to shareholders. Ford reduced its automotive debt by $10.1 billion.

That debt reduction caused Ford to post a one-time gain of $2.8 billion, which allowed the company to report net income of $2.3 billion, or 69 cents a share in the quarter. Ford posted a net loss of $8.7 billion a year ago.

But Ford, the only U.S. automaker not to file for bankruptcy during the second quarter, reported an operating loss of $638 million, or 21 cents a share in the period, excluding special items. That's an improvement over the 63 cents a share Ford lost on that basis in the year ago period.

Analysts surveyed by earnings tracker Thomson Reuters were predicting an operating loss of 48 cents. Shares of Ford (F, Fortune 500) gained more than 9% in early morning trading following the report.

Ford said that total revenue fell 29% to $27.2 billion, as global vehicle sales volume tumbled 25% in the quarter. But Ford's revenue also beat forecasts. Analysts were expecting a drop of 36% to $24.8 billion.

CEO Alan Mulally told investors he expected industrywide sales to stay sluggish around the globe for at least the rest of this year.

"Clearly the road ahead remains challenging. The recovery is likely to be more modest than many of us had hoped," he said on a conference call. "Despite the challenges, Ford's underlying business is getting progressively stronger."

Reduced cash burn and improving market share helping results

The company's auto operations burned through $1 billion in the period, but that too was better than the $3.7 billion in cash it burned through in the first quarter of the year.

Executives said the company's cash burn could top $1 billion in the third quarter but that they did not expect to go through more cash in the second half of the year than the company did in this year's first six months.

Ford said it finished the quarter with about $21 billion in cash on hand following its debt-for-equity swap and decision to tap a $10 billion line of credit in the first quarter.

That cash position allowed the automaker to avoid a government bailout at the same time that the Treasury Department was pumping billions of dollars into rivals General Motors and Chrysler Group to keep those companies alive throughout their bankruptcy reorganizations.

Mulally said that he believes the fact that Ford did not need a government bailout was one factor that helped it improve its U.S. market share in the first half of the year. Through the first six months of 2009, Ford accounted for 16.1% of U.S. auto sales, up from 15.5% in the year-earlier period.

"We are getting a very positive response for creating a strong long-term business, which people think about when they buy a car," he said.

Ford, which has been trailing GM and Toyota Motor (TM) in annual U.S. sales for the past few years, has been pulling closer to Toyota recently. In fact, Ford sold more vehicles in the U.S. than Toyota in the second quarter.

The company said it expects to continue gaining market share in Europe this year as well, and that it remains on track to track to achieve or beat all of its 2009 financial targets, including $4 billion in cost cuts this year.

Ford also reiterated that it expected its North American auto operations would break even or make money by 2011 and stop burning through cash by that time.

Analysts impressed by Ford's performance

Shares of Ford have soared more than 340% in the past five months, prompting speculation that the company will soon sell additional shares as a way to raise cash and further reduce its debt.

When questioned about whether there would be such a stock sale, Mulally would only say that "clearly our plan is to continue to improve our balance sheet as we did in the second quarter."

Prior to the second quarter report, analysts were still forecasting more operating losses for Ford in the third and fourth quarters of this year. Company officials did not give earnings guidance for the third quarter or the full year, but Ford's chief financial officer seemed to hint that higher production levels in the third and fourth quarters could help boost results.

"Volumes do drive our profits," said Ford CFO Lewis Booth.

Analysts said they were impressed by Ford's financial performance in the quarter, considering the weak sales.

Merrill Lynch analyst John Murphy said during the conference call that he calculated Ford's North American plants ran at just a bit above 50% of capacity in the second quarter.

"That's a horrifically low level, and the losses are pretty good performance in the face of that," he said.