We were shocked, shocked to find losses in this establishment: Toyota (NYSE: TM) on Tuesday reported an operating loss of 108 billion yen ($1.4 billion) for the quarter ended June 30, down from a profit of almost 212 billion yen ($2.7 billion) a year ago.

As anyone who has tried to shop for a Prius in the past few months knows, it's no secret that Toyota has been struggling with major supply disruptions in the wake of the March earthquake and tsunami in Japan. Add in the recent surge of the yen versus other major currencies, and for Toyota to post its first operating loss in two years is absolutely no surprise.

But following on the grim outlook put forth by management back in June, today's report contained several rays of sunshine.

A solid beating of grim expectations
All things considered, it was a pretty decent quarter for the Japanese auto giant. Analysts had expected a 78 billion yen loss, which Toyota beat handily. And in fact, on a net basis, the company actually eked out a small profit of about $15 million -- thanks in part to a 43 billion yen tax refund.

Better news for shareholders, though, was a boost in management's outlook for the rest of the fiscal year. (Toyota's fiscal year runs through March 31.) Management now forecasts that the company will earn 390 billion yen ($5.1 billion) for the year, an almost 40% boost from the worst-case 280 billion yen it was forecasting as recently as June.

In raising its outlook, Toyota joins fellow tsunami casualty Honda (NYSE: HMC), which bumped its own profit forecast by 18% on Monday. The story, in a nutshell, is the obvious one: Suppliers hurt by the March disaster are recovering more quickly than expected.

The upshot is that Toyota should be back up to full production capacity within weeks. That's good news. But big challenges remain.

Gathering strength in a tough market
While Toyota (and Honda) have struggled with short parts supplies and limited production capabilities, rivals like Hyundai (OTC BB: HYMTF.PK), Ford (NYSE: F), General Motors (NYSE: GM), and Volkswagen (OTC BB: VLKAY.PK) have moved to eat their collective lunches.

Hyundai in particular has made the most of this particular moment, posting a second-quarter profit gain of 37% and adding significant market share in the United States. Hyundai's compact Elantra and midsize Sonata are top-notch products that arrived at just the right moment, winning comparison tests and consideration from import-focused buyers disappointed by what they're finding (or not finding) on Toyota and Honda dealer lots.

Ford and GM have won some of that business as well, and Volkswagen has continued to press its advantage in emerging markets. But Toyota is determined to make up as much lost ground as it can: The company said it will hire 4,000 extra workers in anticipation of a "production recovery phase" starting in September, and Toyota's Senior Managing Officer Takahiko Ijichi said that the company would boost incentive spending in the United States in a focused effort to regain lost market share.

The bigger problem on the horizon
Regaining market share is one thing, but boosting profits may be a more elusive goal, despite the more optimistic forecasts heard on Tuesday. Toyota books its earnings in yen, and the yen is currently near record highs versus the dollar. That means that sales made in dollars are worth less than they were last year. The yen's appreciation over the past year has cost the company nearly $4,000 per car in profits, Ijichi said.

That's a big hit, and the company's already-squeezed margins are going to get squeezed further by that incentives campaign. GM veterans can tell you all about the "joys" of trying to compete with global competitors when handicapped by a fixed-cost disadvantage and a reliance on incentives. It's hard to make money in that situation without, as auto executives say, taking cost out of the products.

That, in turn, can lead to cars that feel cheap and don't stand up well to comparisons with class leaders, and over time that will lead to market-share losses. (Sounding familiar yet?) Think about this: On Monday, news broke that Consumer Reports had dropped the new Honda Civic from its "Recommended" list, because it no longer compared well with the best products from companies like Hyundai and Ford. Honda, said the respected consumer advocate, seemed to go backwards while others moved ahead.

For Toyota, keeping its vaunted products from following suit could be quite a challenge.

Worried about the impact of higher energy prices? You're not alone -- but here's the good news: It's not too late to profit. In the new special report," 3 Stocks for $100 Oil ," expert Motley Fool analysts name three outstanding companies that should benefit handsomely from rising oil prices. The report is available free of charge for Fool readers -- and here's your chance to get instant access.