(Fortune Magazine) -- These are brutally difficult times for automakers worldwide, but as crises go, this one could be a lot worse for Wendelin Wiedeking, Porsche's chief executive for the past 16 years.

Thanks to an astute mixture of long-term strategic foresight and short-term financial wizardry, Wiedeking has Porsche headed into this downturn in an extraordinarily strong position. The company is sitting on a $20 billion mountain of capital - more money than the U.S. government is injecting into GM, Ford, and Chrysler combined.

More important, Wiedeking, 58, has secured Porsche's future through an audacious David vs. Goliath takeover of Volkswagen, Germany' largest automaker and a company that has so far weathered the crisis better than most of its peers. "Wiedeking very cleverly purchased a life insurance policy for Porsche by buying VW," says Peter Schmidt, an auto consultant based in Britain. "He's a brilliant, focused leader who grabbed VW for peanuts and is making a fortune out of it."

Schmidt is referring to a feat that guarantees Wiedeking a place in the record books: Porsche's profits before taxes of $11.6 billion in the fiscal year ended in July were actually larger than its total revenues from sales of $10.2 billion. Not even Google has profits exceeding 100%. Only 12% of Porsche's profits came from making cars. The remainder is the fruit of a brilliantly sophisticated stock-hedging strategy (yes, sometimes they do work) that was hatched by CFO Holgar Hrter before Porsche started buying into VW, and ended up panicking short-sellers and enriching the automaker.

The gambit also let it acquire VW stock at a price well below market. On Jan. 5, Porsche announced that it now owns just over 50% of VW and holds options that would raise that stake to 74%. The joke making the rounds in industry circles is that Porsche is a hedge fund attached to a car company. Porsche isn't laughing. It says it hedged only to further its strategic goals as an automaker.

As a manufacturer producing just 100,000 cars per year for well-heeled clients, including bankers and hedge fund managers, Porsche could now be in a dire situation. But though its sales have slumped in recent months along with the rest of the industry's, the company seems poised to grow. This is a testament to Wiedeking's leadership, which has transformed the German sports car maker from a business that was close to collapse when he took it over in 1992 to the world's most consistently profitable automaker and the firm regularly chosen by German managers as the nation's best run.

A man of the people

Wiedeking likes to think of himself as a man of the people - he regularly walks through the assembly line at the Stuttgart factory and tools around potato fields near his home in a vintage Porsche tractor. That folksy image has been tarnished recently by disclosures about his salary: Last year he made $100 million, sparking an outcry in Germany. He's unapologetic, saying he earned it.

A mechanical engineer by training, he's obsessed with detail and loves poring over technicalities in search of perfection. After sitting down with Fortune in his Stuttgart office, located in a brick building next to the factory where the 911 is produced, he rushes off to inspect a new corporate museum that Porsche is about to open. He quickly spots a sloping ceiling with a water sprinkler low enough to be tampered with by visitors, and orders the sprinkler moved.

Such attention to detail is an important part of Wiedeking's management style, as is his willingness to seek dissenting opinions. Indeed, he encourages his managers to air their disagreements in full, so that he can make well-informed decisions. When it comes to pricing new models, for example, he doesn't want to hear just the suggestions of his sales executives. So he regularly charges his strategic planning team to come up with their own proposals - and then lets the two sides slug it out. "I provoke internal discussions," he says. "I want managers to put forward their position, to fight for decisions. Sometimes there's a bust-up, not just between me and them but with one another."

That blunt, confrontational style was a critical element in saving Porsche during the last serious downturn. Wiedeking joined the automaker fresh out of engineering school in 1983 as an assistant to the head of production. He left five years later to work at a supplier but returned in 1991 as production head and was made CEO in September 1992. At the time Porsche was sliding into a life-threatening crisis. It had boomed in the mid-1980s on the back of buoyant demand from America, which then accounted for about two-thirds of sales. But as the U.S. economy hit the skids, Porsche car sales dropped 80%, and its losses piled up.

It wasn't just the demise of a key market that was painful; Porsche was also hampered by antiquated production methods. Some 20% of its parts were delivered three or more days too late, for example. Wiedeking, who had been deeply impressed by what he'd seen on visits to Japanese auto firms, believed that only a radical, "lean manufacturing" cure would save the company. He flew in teams of the same Japanese consultants who had helped Toyota and gave them free rein. "A cultural revolution from top to bottom" is the way he describes what happened next, as the consultants organized the workforce into teams and one by one eliminated poor practices. Wiedeking made one now-fabled appearance on the assembly line wielding a circular saw, which he used to cut down the roof-high racks of spare parts that towered over the production line.

Porsche quickly became an exemplary proponent of "just-in-time, just-in-sequence" manufacturing, and its fortunes revived. But Wiedeking's revolution wasn't over yet. His next moves, focusing on new models, consisted of outsourcing the expensive parts of the manufacturing process as a way of keeping overhead low and boosting Porsche's profit margins.

The guts of the Cayenne model are manufactured in Bratislava, Slovakia, at a VW plant alongside VW's own Touareg SUV and the Audi Q7, although final assembly takes place in Porsche's plant in Leipzig, Germany. The new Panamera four-door luxury sedan, which will be launched this spring, is manufactured primarily at an underutilized VW plant in Hanover. All that translates into profit margins per car that Detroit can only fantasize about. The company earned more than $1.4 billion before taxes last year on its autos, an average of some $14,000 apiece - and its margins are about double those of BMW. Consultant Schmidt calls Porsche a "huge money-printing machine."

Wiedeking realized, however, that as a boutique Porsche did not have what it takes to compete in an increasingly global market. In 2005 the CEO started buying into VW, at a time when VW stock was below $50. Today it's at almost $400, and in October it briefly hit more than twice that when Porsche revealed that it indirectly owned options to acquire 74% of VW. (Analysts are guessing that the company is paying an average price for VW stock of $100 to $150 per share.)

The announcement sparked such a panic by short-sellers that the company offered to boost liquidity by selling options on more than 3% of VW stock - making in the process another tidy profit that Goldman Sachs estimates to be about $8 billion. Among the victims of the Porsche VW stock squeeze was a leading German industrialist, Adolf Merckle, who committed suicide in early January after losing hundreds of millions of dollars. Part of those losses came from his disastrous shorting of VW shares.

Filling some holes

Apart from the opportunity to snap up a big player for a bargain price, there was another reason why the tie-up made sense for Porsche: new European environmental regulations that will strictly limit carbon emissions from autos, starting in 2015. Porsche was not likely to meet the emission targets and would thus face huge fines. But since emissions will be measured on a group-wide basis, becoming part of VW, which sells many low-emission cars, would remove the problem. In that sense, it's a case of Porsche's needing VW more than VW needs Porsche. "You buy what you need," Wiedeking says. Another thing he does need is a bigger presence in the U.S. market. VW will manufacture there for the first time in some 20 years, after it completes a $1 billion factory in Chattanooga.

VW also gives Wiedeking the scale to play in emerging markets, where auto analysts expect most growth to occur. VW sells almost as many cars in China as it does in its home market, and its Skoda brand is strong in Eastern Europe. Wiedeking talks about how he's itching to take on Toyota on its home turf. "VW for too long left Asia to the Japanese," he says. Above all, he believes his strategy of twinning Porsche's future with VW's is being vindicated by the sudden downturn in the world economy. "Can you imagine what would be happening now if we hadn't done this? Imagine the discussion that would be going on about Porsche's ability to survive!" he says.

Not all has gone smoothly, however. Porsche's power play provoked a mixture of fear and loathing at VW, and the reaction has taken Wiedeking by surprise. When the CEO promised in a German interview last year that there would be "no sacred cows" at VW, that company's top labor official, Bernd Osterloh, fired back, accusing Wiedeking of nurturing "dangerous power fantasies" and having "zero finesse."

More surprisingly, some of the heat has come from a key shareholder, Ferdinand Pich, a member of the extended family that owns Porsche. He also plays a central role at VW as head of the supervisory board. Amid the turbulence caused by Porsche's move, Pich for a while took VW's side, to the delight of the labor unions there, and the German press last year was filled with leaks that he wanted Wiedeking's head. In the end, Pich backed off after the matter was thrashed out at a tense September meeting of family shareholders, who unequivocally endorsed Wiedeking's leadership.

Wiedeking says the criticism is understandable. "Of course it hurts when the little firm buys up the big one. It couldn't be otherwise," he says, but adds that the "scars are now slowly healing." As for Pich's gunning for him, Wiedeking shrugs. "I'm relatively relaxed about it all," he says. "The shareholders need to decide what management they want, but I'm not going to force myself on anyone. If they think they need a change, I'll accept that." He adds, "I've earned a lot of money. I am very independent. Ask my colleagues: I've never been so relaxed."

Spoken like a man used to being in the driver's seat.