It's been one heck of a rough year for Toyota (NYSE: TM). While the company has worked hard to put the sudden-acceleration recall PR disaster behind it, questions about the automaker's once-vaunted quality linger.

Those questions, together with a product line that is starting to look a bit lackluster, are taking big bites out of the automaker's sales all over the world. Toyota was the only one of the major automakers to see U.S. sales decline in October, and results were similarly dismal in other key markets around the world.

So how is it that the company turned in a solid profit?

Smoke and mirrors?
The signs were certainly looking grim: Toyota was the only major automaker to report a sales decline in the U.S. in October. The company saw a 6% decline in China even as key rivals posted double-digit gains. Sales at home in Japan have been hit by an end to the government "eco-car" incentives that drove Prius sales to such high levels. Year to date, U.S. sales are up a paltry 1.4%, despite increasing sales incentives to fend off rivals Honda (NYSE: HMC) and Ford (NYSE: F). And the strong yen has eroded profits from overseas markets still further, just as it has for other big Japanese exporters like Sony (NYSE: SNE) and Panasonic (NYSE: PC).

Despite all that, the company announced a 98.7 billion yen ($1.2 billion) profit for its second quarter (July through September), up bigtime from 21.8 billion yen a year ago.

An epic series of global recalls, a big bump in U.S. incentives spending, slipping sales in China and at home, and a strong currency tide flowing the wrong way ... and yet profits were up 350%. How'd that happen?

Not as bad as you think
Well, despite the PR nightmare and slippage in key markets, global sales were up: Toyota said that it sold 585,000 more vehicles around the world in the first half than it did last year. In fact, the company saw incremental improvements in each of its global regions. Losses narrowed in Japan and Europe, while profits were up everywhere else.

Those profits weren't without caveats, though: While much of the company's improvements were attributed to cost-cutting efforts, in North America, the company cited "improved earnings from the financial services segment." No, that's not a euphemism for scary derivatives trading (though they did admit to losing 9.8 billion yen on interest rate swaps). In a nutshell, Toyota was able to get more than it expected for cars coming off leases, thanks to the unexpectedly strong used-car market in the U.S.

Unfortunately for Toyota, that's not a trend that's likely to continue over the long term.

What's next
I think Toyota will see a gradual recovery in worldwide sales as the recall disaster slips further into the rear-view mirror, at least to some extent. But between those recalls and loudly trumpeted improvements in quality and products from surging rivals Ford and Hyundai, those sales will be harder for Toyota to win than they have been in years.

Toyota's success was driven more than anything else by its reputation for quality. With that reputation dented, many of the company's products suddenly look like lackluster entries next to the best of the competition. Its years-long effort to become the U.S.-market sales leader seems to have been wasted, as the company lags in third place behind suddenly mighty Ford despite that big bump in incentive spending. Worse, its hard-won standing as the global sales champ will be fiercely challenged by awakening-giant General Motors, perhaps as early as next year. And ever-more-impressive Hyundai is working overtime to do to Toyota what Toyota did to the Detroit automakers a few decades back.

Long story short, CEO Akio Toyoda has his work cut out for him. Toyota continues to push the green frontier, with a plug-in Prius on the way and collaborations with eco-innovators like Tesla Motors (Nasdaq: TSLA). But it'll take a lot more than new hybrids to restore Toyota's luster, and its competition is fiercer than ever.

Want to keep up with news on Toyota? Add it to My Watchlist, which will find all of our Foolish analysis on Elon Musk's new best friends.