How Hewlett-Packard lost its way

FORTUNE — A few months after she took over as the CEO of Hewlett-Packard HPQ last September, Meg Whitman held one in a series of get-to-know-you meetings with employees. To say the audience, a group of software engineers and managers, was sullen would be an understatement. As Whitman spoke, many of them glared at her. Others weren’t making eye contact with their new boss. Their heads were down, and they were tapping furiously on handheld devices.

“Your comments are being live-blogged,” one employee told her defiantly. Whitman challenged the man. “You all have taken leaking to a new art form,” she said. “It’s a sign of an unhappy company. You wish HP ill.” The tapping suddenly stopped, and as the room fell silent, the mobile devices were lowered.

The employees’ open contempt for the head of the company and Whitman’s acknowledgment of their misery were signs of just how dire things had gotten inside the technology titan after a humiliating series of epic stumbles last year. Just in the few months before Whitman became CEO, there was the costly failed launch of a tablet computer, a mortifying public waffling over whether to spin off the company’s giant personal computer business, and then the drumming-out of its third CEO in less than seven years.

If only HP’s troubles were confined to a few months in 2011. For a decade now the company has sometimes seemed more like a tawdry reality show than one of the world’s great enterprises. The public dysfunction started with the vicious infighting over HP’s merger with Compaq in 2002, which reached its nadir when the company’s high-profile CEO, Carly Fiorina, pilloried Walter Hewlett, a board member and son of a company founder, for daring to voice his opposition. There was a board riven by feuds — so out of control that some directors were leaking secrets to the press while the chairman of the board was hiring private investigators to obtain their phone records (and those of reporters) to uncover the perpetrators. That bit of skullduggery ended with the company’s chairman and its CEO both dragged before Congress to explain themselves under oath. Then came the ouster of the company’s putative savior, CEO Mark Hurd, after allegations relating to his interactions with a marketing consultant who had been an actress in risqué movies; both parties absolutely, positively, categorically denied that there was any hanky-panky.

Dr. Phil could fill a month’s worth of shows just examining HP’s board, whose dynamics have resembled those of rival junior high school cliques more than what is supposed to be a sage guiding force. At times, as we’ll see, HP directors have refused to be in the same room with one another and have accused each other of lying, leaking, and betrayal. Time and again they’ve failed in their choice of CEO — their most important task — selecting a new leader whose most salient trait is that he or she is the opposite of the last one.

All of this has impeded the company from tackling the fundamental problem it faces: Simply put, Hewlett-Packard has lost its way. The company is in the midst of an existential crisis. It remains a behemoth, No. 10 on the Fortune 500, with $127 billion in sales last year and $7 billion in earnings. But the trajectory is ominous. Those profits, for example, were 19% lower in 2011 than in the previous year. HP’s business is under siege on almost every front, losing market share and facing declining margins.

It was a combustible mixture: long-term threats to the business combined with an impaired board and an ill-chosen CEO in Léo Apotheker (LAY-o AH-po-teck-er). The three ignited disastrously during the 11 months that the 58-year-old European software executive ran HP. Indeed, there’s no better way to understand the company’s plight today than to examine his tumultuous tenure. A Fortune investigation reveals that the turmoil of Apotheker’s reign was even more intense (hard as that is to believe) than previously reported. From the slapdash hiring of a man with no experience in HP’s biggest lines of business, to the half-baked ways in which the company tackled major strategic decisions; from the never-before-reported internal challenges to Apotheker by top executives, to the fact that HP chairman Ray Lane was a major force in the company’s strategic decisions — which he has since blamed on Apotheker — the full story of HP’s convulsive year has never been told. This article is based on interviews with more than 70 current and former directors, executives, and employees of HP, SAP (where Apotheker once worked), and other companies in the industry, as well as hundreds of pages of company and legal documents, many of them never before made public. (Citing a confidentiality agreement with HP, Apotheker declined to meet with Fortune in Paris, where he now lives.)

With Whitman, 55, now in place, the acrimony at HP seems to have eased. So far her strategy amounts to this: Let’s execute better while we figure out our long-term plan. That’s fine, as far as it goes. But the company will never come close to reclaiming its former glory unless she and the board can find a way to function together and, most important, until she can answer the real question: What is HP?

The saga of HP’s 11 months under Léo Apotheker begins in November 2010. To understand it, you need to appreciate what he found and how HP got to that point. The company seemed strong at that moment, its swagger restored during the five years Mark Hurd had been in charge. Earnings per share had quadrupled. The stock price had doubled. HP was No. 1 in PC shipments, No. 1 in printers, No. 1 in servers.

But just under the surface was a very different reality: HP was traumatized, its employees disengaged. Internal “voice of the company” surveys revealed that morale had cratered. One top executive told Apotheker she felt “maimed” by Hurd’s hard-charging style. A company hailed for its vaunted “HP way” — which emphasized employee autonomy — had stifled creativity to the point where workers now had a rueful phrase to describe the way they tuned out and pretended to be clueless when executives asked them to do something: “flipping the bozo bit.”

HP was barely innovating. The company didn’t boast a single hit consumer product even as 67% of its revenue stemmed from hardware. Apple AAPL had shown the riches awaiting those who invent hit devices. But there were no iPhones or iPads in HP’s bland array of products. And Apple was only one rival for HP, whose diverse businesses meant it also competed with enterprise hardware and software companies such as IBM IBM and Oracle ORCL and consultants such as Accenture ACN.

Faced with pressures on every side, HP had seen its numbers begin to slide. After nearly doubling in Hurd’s first three years, for example, free cash flow sank from $12 billion in 2008 to $8.4 billion in 2010, his last year.

By contrast, the company HP dreamed of being, IBM, had soared by taking a different tack: It dumped its PC business and focused on high-margin software and services. That prompted what is probably an apocryphal, but telling, anecdote among enterprise techies: Two visiting consultants are waiting for the elevator at a big company’s headquarters. One is from HP, the other from IBM. The consultant from Big Blue pushes the up button to visit the CEO on the top floor. The HP man, by contrast, hits the down button to see the IT guy in the basement. The message was clear: IBM was consorting with kings while HP was on hands and knees, fixing the plumbing. It wasn’t just a metaphor either: IBM’s pretax profit margins, just under 20%, were more than double the 8.7% HP achieved in Hurd’s last year.

HP had been operated with an eye toward the short term. Hurd emphasized financial management. Revenues grew largely because of acquisitions — including the Compaq deal, HP bought 86 companies under Carly Fiorina and Hurd — and profits multiplied mostly because of Hurd’s ferocious cost-cutting and growth in the PC business.

Hurd’s early initiatives to pare spending were valuable and necessary. But as time went on it became harder to find waste, and the results became extreme. Employees practically needed an act of Congress to get approval to buy a piece of software. The headquarters of the tech company did not have Wi-Fi. And some minions took Hurd’s edicts to self-defeating lengths. At HP’s office in Fort Collins, Colo., for example, the lights shut off automatically at 6 p.m. every day, effectively forcing workers to go home. An intrepid few brought their own lamps to the office, only to be scolded by facilities managers, who told them to remove the lights.

Decay had begun to show in some HP offices. Mice skittered in the corridors. Spiders fell from cracked ceilings. As the company cut back on trash pickups, detritus piled up, and in one location workers took garbage home in their cars. Upon arrival, Apotheker was informed that HP was missing 85,000 chairs. The figure was so farcical that he had to check to make sure it was right. It was. Hurd might not actually have “burned the furniture to please Wall Street,” as HP’s chairman, Ray Lane, would later disparagingly put it. But the Hurd era’s external success had concealed internal deterioration.

Before Apotheker ever came to HP, the company was known for its fractious board. Individual directors would cycle in and out, yet somehow the group seemed constantly divided by personal rivalries, bickering, and leaks to the press.

In one HP office, the lights went off at 6 p.m. to save money. Workers were scolded for bringing in their own lamps.

With his forceful personality and a rising stock price, Hurd, 55, managed to suppress the worst contentiousness. But his departure brought out the sharpest antagonisms in the board. Directors argued for an intense week before announcing Hurd’s resignation on Aug. 6, 2010. Technically Hurd was pushed out for false explanations on expense accounts relating to interactions with contractor/actress Jodie Fisher. Despite a letter from Fisher’s lawyer charging sexual harassment, the company found no evidence that Hurd had harassed Fisher. What doomed him was the board’s view that he had misled them when he initially denied any relationship with Fisher. (A spokesman for Hurd declined to comment on the record; the ex-CEO has previously denied any impropriety, financial or otherwise.) Hurd was replaced on an interim basis by CFO Cathie Lesjak, a two-decade HP stalwart who made it clear she wasn’t a candidate for the permanent CEO position.

The board’s tensions did not abate when Hurd left. One of the ex-CEO’s staunchest allies on the board was Joel Hyatt, the founder of a chain of legal clinics and later the co-founder of Current TV. Hyatt was prickly. He didn’t hide his contempt for the two directors who had led the investigation of Hurd, Robert Ryan, an ex-CFO of Medtronic MDT, and Lucille Salhany, the former chairman of Fox Broadcasting. He claimed they had railroaded the former CEO. For their part, Ryan and Salhany couldn’t believe how long it had taken their fellow directors to recognize the gravity of what they viewed as Hurd’s lies.

There was an almost dizzying array of ambitions and gripes among the directors. Lawrence Babbio, the former vice chairman of Verizon VZ, hoped to be named HP’s chairman. John Joyce, a former CFO of IBM, was vying to be president of HP. Several complained that Hyatt had been — and was still — channeling board discussions to Hurd. (Hyatt says his conversations with Hurd were proper and fully disclosed to the board.)

Hoping to mollify Hyatt, the directors named him co-chairman of the committee to pick a new CEO and lead the transition. But Hyatt wasn’t placated for long. He was furious to learn that two directors had addressed employees about Hurd’s departure without inviting him. “My colleagues aren’t interested in my help,” he seethed, resigning his title as co-chairman, though he stayed on the committee. When an article detailing the sexual harassment allegations against Hurd appeared, Hyatt accused his fellow directors of leaking. “We took a blood oath” to keep board matters private, he fumed, “and it didn’t last 24 hours.”

Despite the rancor, the search committee members tried to focus on finding a new CEO. They picked Spencer Stuart’s James Citrin to run the search. (Citrin declined to be interviewed for this article.) Smooth, gregarious, wired into the C-suites of the world’s biggest companies, Citrin had a network that few could match. He embarked on a two-track search, examining both internal and external candidates.

Four internal aspirants stepped forward. The strongest was Todd Bradley, the head of HP’s personal computer group. His group generated $41 billion in annual revenue and had tripled its profitability during his tenure. But Bradley had shortcomings. His critics said he tended to mumble in presentations and was perhaps a bit too cozy with the press. His record as an infighter had made him enemies. Several top executives said they would resign if he were named CEO. For various reasons the other three internal contenders — Ann Livermore, Tom Hogan, and David Donatelli — were also ruled out.

Hurd certainly hadn’t made the board’s mission easy. At various times when he was CEO he had told three of the internal candidates they were his heir, according to people familiar with the matter. Hurd then turned around and told the board that none of them was ready to be CEO. Needless to say, that left bruised feelings that would ultimately sour relations with the next CEO.

Citrin was keen on Ray Lane, a managing partner of the venture capital firm Kleiner Perkins. Lane had a track record in enterprise software and one of the biggest Rolodexes in the Valley. After a successful turn as Oracle’s president in the 1990s, Lane was pushed out by CEO Larry Ellison in 2000. He left an extremely wealthy man but bearing a grudge against his former boss. Lane was tempted by the HP job. But at age 65, he had young kids and other business commitments. He didn’t want to work CEO hours and he preferred not to travel much. Lane withdrew after it was made clear that being chief of a $127 billion corporation is all-consuming.

If not Lane, then whom? Citrin was enthusiastic about a former enterprise software CEO, whose career he’d been tracking. But hiring him would take courage. He’d been fired after a short, rocky tenure. HP directors were skeptical. But the more they learned, the more impressed they became.

The man had expertise in enterprise software, an area the board thought HP needed to move deeper into. He spoke five languages and had worked on three continents, a major plus considering that more than 60% of HP’s business was now overseas. He was a bold choice, Citrin told the search committee, and if they picked him, they would be remembered for making “one of the best CEO picks ever.”

Apotheker’s rise had been impressive. He was born in 1953 to Polish refugees who settled in Germany after World War II. His father acquired a textile factory with help from the Marshall Plan. Apotheker spent his first eight years in Aachen, Germany, and then moved to Belgium. He studied international relations and economics in Israel.

In 1988, Apotheker joined SAP SAP, then a small German business software concern, and launched its operations in France and Belgium. Apotheker was a master salesman, deploying cold logic rather than charm. “He could sell ice cream to an Eskimo,” says one former deputy. “But he wouldn’t just sell ice cream. The customers loved the insights they were getting out of this guy.” Apotheker’s brilliance and his astute push for key acquisitions such as BusinessObjects helped SAP become an international force. By 2005 he was a contender to become SAP’s CEO.

Still, it sometimes seemed as if there were two Apothekers. There was the awkward, self-deprecating version who kept a statue of a clown on his desk, a gift from his children, to remind himself to be humble. And there was the imperious tyrant who could be so overbearing that his enemies dubbed him the Sonnenkönig, the Sun King.

The stories of his nastiness flew around SAP. One poor fellow was only a few sentences into a presentation when Apotheker began bombarding him with questions, according to two people who were present. After several minutes under this fusillade the man sank to the floor, whimpering, “What do you want me to do? What do you want me to do?” Apotheker was capable of absurd flights of invective. “Bring me the liver of that asshole,” he raged on one occasion to a stunned deputy, who didn’t know whether to laugh or to cry. “I will eat it for breakfast.”

An SAP presentation, part of a campaign Apotheker led to “disrupt” Oracle, portrayed Larry Ellison as a fly.

Apotheker thought of himself as an honorable man, according to colleagues. But he viewed the world as a place filled with retribution and betrayal, so he was willing to throw an occasional elbow if need be. After all — at least, in his mind — that’s what everybody else was doing. Some of the seeds for Apotheker’s downfall at HP were planted in precisely that sort of thinking.

It began with a feud between Apotheker’s prior company, SAP, and Oracle. As SAP saw it, Larry Ellison’s company had barged into its turf — back-office software — in 2004, buying PeopleSoft, and later Siebel and others. Ellison, who seems to revel in psychological warfare, gleefully trashed his rival in public. (An Oracle spokeswoman declined to comment.)

In response, Apotheker led a campaign called Project Apollo. The secret operation was rolled out at SAP’s summer sales meeting in July 2005. The goal was to motivate the troops by “highlighting the falsehoods Oracle tells about SAP” and to “demonize Larry Ellison to the field,” according to a memo prepared for the event.

The presentation included a video that depicted Ellison’s head on a fly’s body. It was time, Apotheker said as the fly buzzed above him, to “treat Oracle like the pesky, annoying bug it is.” At that point, a can of bug spray was aimed at the fly. “And that is how we intend to treat the annoying lies,” Apotheker intoned, “by swatting them away with facts.”

But Project Apollo wasn’t just a truth squad. It became an expensive and ultimately self-defeating attack strategy. The plans, outlined in SAP documents that emerged in subsequent litigation, included a “disinformation campaign” against Oracle and efforts to “disrupt” its rival.

Apotheker ordered SAP to “exploit” the opportunities “to the hilt.” One part of the campaign involved a then-newly acquired software company called TomorrowNow, which provided service for users of PeopleSoft and Oracle software, among others. SAP hoped to use TomorrowNow to lure customers from those companies. The problem was that, as even SAP would later admit, TomorrowNow was able to provide cheap service because it was secretly and illegally downloading software from Oracle.

In 2007, Oracle sued. Apotheker was grilled for eight hours by Oracle’s lawyers. He dodged and weaved. He insisted SAP shut down TomorrowNow after it learned of its unethical practices. Apotheker remained bland and vague throughout the deposition. Only when the lawyers read him SAP’s “attack plan” to “seek and trash Oracle” did Apotheker flash a rare grin. He shouldn’t have been smiling. Within three years the suit would blow up in his face.

In June 2009, Apotheker was promoted from co-CEO to CEO. The world economy remained fragile, and like most companies, SAP was suffering. The company was forced into global layoffs for the first time, infuriating its unions.

Apotheker made things worse for himself. When he was co-CEO, SAP had raised the lucrative fees that it charged to maintain its software. Customers resisted, but even as the economy tumbled into recession, Apotheker wouldn’t yield. For months he refused to roll back the increase and squabbled in public with his customers. Only after clients had fled did Apotheker finally relent.

It was too late. In February 2010, SAP’s executive chairman and co-founder, Hasso Plattner, called him. After all the hard things that had transpired, Plattner told him over the phone, SAP needed a “new face, a happy face.” Apotheker was instructed to leave that day. Stunned, he retreated to his home in Paris and sank into a deep funk. Six months later, Apotheker got a second chance. It was Jim Citrin calling about the CEO job at HP.

Citrin’s report on Apotheker largely defended his performance. It quoted insiders saying that the CEO fell victim to a perfect storm of circumstances while trying to make bold strategic changes. The report did mention the botched maintenance hike, but it failed to explain the leadership deficits that undid Apotheker at SAP — faults that would undermine him at HP: his negativity, his nastiness, and his unwillingness to be coached.

The announcement that Apotheker had been named CEO and Lane would be chairman came on Sept. 30, 2010. The Apotheker appointment shocked the tech world. Media reports had predicted the new CEO would be Todd Bradley or Ann Livermore. Within HP, jaws dropped. Léo who? SAP had one-eighth its revenue. For crying out loud, there were HP senior vice presidents who ran units bigger than all of SAP.

For the board, no other candidate had come close. Apotheker had struck just the right notes: He understood the strengths and weaknesses of HP and of key executives; he spoke of the need to restore innovation. True, he was an outsider, but he acknowledged his lack of experience and the board had a solution: Lane, a Silicon Valley blueblood, would guide him. As part of being hired as chairman, Lane had asked who the new CEO would be; he had enthusiastically endorsed Apotheker.

The full board never met Apotheker and Lane before hiring them. As one director told New York Times columnist James Stewart, many were too exhausted by the fighting. Board members did discuss the consequences of hiring two men without hardware backgrounds, but they felt that Bradley and the other HP executives could coach them. They briefly discussed Oracle’s litigation against SAP and were assured there was little likelihood Apotheker would become ensnared in it. It was no big deal.

Still, Oracle was emerging as a potential plague for other reasons. Larry Ellison was friends with Mark Hurd and livid at HP’s decision to fire him. Ellison publicly accused the board of making “the worst personnel decision since the idiots on the Apple board fired Steve Jobs many years ago.” Only one month after Hurd resigned from HP, Oracle hired him as co-president.

The news exploded inside HP, which had a complex relationship with Oracle. The two companies were competitors — but also partners, sharing some 140,000 customers. Within 24 hours of the news, HP filed suit against Hurd, claiming he had put the company’s most valuable trade secrets in peril. (Even that move had unintended consequences inside HP. Its general counsel, Michael Holston, filed the suit without consulting the full board. Director Hyatt was furious. “You did what?” he bellowed at Holston. Hyatt thought it would jeopardize HP’s relationship with Oracle.)

When Ellison learned that HP had hired two Oracle antagonists, he swung back into action. The timing of Apotheker’s appointment was fortuitous. His first day of work, Nov. 1, coincided with the start of Oracle v. SAP, the trial to assess the size of damages for the theft of Oracle software by SAP’s unit, TomorrowNow. Oracle’s lawyers announced they planned to subpoena Apotheker if he came within 100 miles of Oakland, where the trial was being held.

Apotheker had just taken the reins of America’s largest tech company. Many a new leader would fantasize about riding in on a white stallion, flags flying, to take charge. But Apotheker was advised not to testify. So instead of making a dramatic entrance at HP’s Palo Alto headquarters, Apotheker was forced to stay away. He took off on what the company dubbed a “listening tour” of its global empire, visiting offices around the world: the U.K., Germany, France, Brazil, Singapore, New York, and Houston.

It was a PR fiasco. Apotheker was mocked. Bloomberg TV sent a reporter to look for him just outside the 100-mile subpoena service limits. WHERE IN THE WORLD IS LÉO? sneered the crawl at the bottom of the screen. It only got worse when Oracle was awarded $1.3 billion in its suit against SAP. (It was later reduced to $272 million; Oracle rejected the judgment and the suit is going back to trial.) Ellison’s company had succeeded in making Apotheker look weak and defensive before he even set foot in Palo Alto.

Despite the turmoil, there were fleeting moments when it appeared Apotheker might enjoy a honeymoon at HP. Investors seemed heartened by his first moves. He wanted the personal computer and printer groups to focus more on business-to-business sales, and he sought to move the services operation into higher-margin areas. He planned to focus HP’s software on big data analytics, a goal he said could be achieved without expensive acquisitions.

Employee morale started to improve. Apotheker undid salary cuts that had occurred under Hurd. He held a series of town halls and breakfasts. He brought in a European youth orchestra to play for the troops at headquarters. He toured HP’s labs and vowed to bring innovation back.

But events quickly turned against Apotheker. In February 2011, just three months after he took over, HP missed its quarterly revenue estimate. Both the PC and services divisions had underperformed. Apotheker directed his ire at himself, to some extent, and even more at HP’s CFO, Lesjak. Now the stock was being pounded — down 10% in a day — because the company hadn’t delivered.

Then, in March, came a disturbing flare-up in what was starting to look like a long-term conflict with Oracle. HP’s frenemy announced it was discontinuing software development for servers that used Itanium chips made by Intel. It was a stick in the eye of HP, the biggest manufacturer of such equipment (which competed with Oracle’s servers). The servers generated more than $1 billion in profits for HP. Now the business was imperiled.

Furious, HP filed suit, claiming Oracle’s move violated the settlement in the Hurd case, in which the two companies promised to conduct business as usual. The suit brought more bad press, exposing embarrassing documents, which revealed that Intel had tried to discontinue Itanium because the chips were losing money. The reason the company hadn’t done so was because it received $690 million in subsidies from HP to keep manufacturing the chips until 2014.

The threat to the Itanium business underscored HP’s vulnerability, and it affected Apotheker’s thinking. As he pondered the company’s strategic direction, he began to see the need for a more fundamental change. In his mind, the company simply couldn’t continue with its strategy of being the most cost-effective hardware supplier and making modest incremental investments in software.

Apotheker started to believe that what HP needed was a transformation on an IBM scale, but conducted in a much shorter time frame. HP should spin off its massive but stagnant PC division. And HP needed to really commit to the software business by buying a big data analytics company.

There was also a third major initiative, this one a holdover from the Hurd era. Apotheker’s predecessor had purchased Palm Inc. in July 2010 for $1.8 billion — one of his main attempts to fashion a growth strategy. (Hurd also recruited venture capitalist and onetime Internet wunderkind Marc Andreessen to join the board and inject some fresh thinking.) Palm was planning to launch a tablet computer — a product sorely lacking in HP’s stable — and it would use a new operating system called webOS. Technology denizens praised the operating system, which raised the prospect that HP could make giant profits on software (rather than letting the big money go to Microsoft (MSFT)). And the buzz on Palm’s tablet was good. Maybe, just maybe, HP would have a new hit — a quick infusion of profits and prestige.

But before Apotheker hatched his strategy, he and Lane reshuffled the board. The process was messy and contentious. The media would portray the changes as evidence that Apotheker had taken control of the board. In truth, it was Lane who would consolidate his grip.

HP directors were asked for a show of hands: Which were willing to resign?

In November 2010, the same month Apotheker took over as CEO, the usually silent director Ken Thompson, the former chief of Wachovia, declared at a board meeting that every director should tender his or her resignation. That way Lane could pick which directors to keep. The suggestion shocked some board members, but before they could even respond, general counsel Holston jumped in: Letters of resignation aren’t feasible, he told them, since securities laws would require them to be publicly disclosed. So Thompson asked for a show of hands: Who would offer to quit? Most directors raised their arms.

Lane quickly established a committee — Apotheker, Babbio, McKesson CEO John Hammergren, and himself — to decide which heads to lop off. The jockeying began almost instantly. Hammergren wanted to oust Salhany; in return, she viewed him as arrogant and egotistical. Most of the directors couldn’t stand Hyatt and pushed for him to be dumped. Three had refused to sit on committees with him; Andreessen had gone so far as to skip an entire board meeting so he wouldn’t have to be in the same room with Hyatt.

In late December, Lane asked the two directors seen as Hurd’s main defenders, Hyatt and former IBM CFO John Joyce, to step down. Then, “as a matter of balance,” Lane told the two directors who had led the Hurd probe, Ryan and Salhany, that they needed to depart also. Ryan and Salhany were upset. They’d invested significant effort in the investigation and felt their work had been vindicated. Why did they have to go? In the end, rather than cause yet another fight, Ryan and Salhany agreed to leave, signing prepared resignation letters.

Once that was accomplished, Lane set about restocking the board. In January 2011, the company announced five new directors. One, Dominique Senequier, CEO of AXA Private Equity, was seen as an ally of Apotheker’s. The rest were Lane’s picks. The most notable was Meg Whitman. She and Lane had forged a friendship years earlier; as Oracle president he had helped save the day after eBay EBAY experienced a major server crash. Lane later supported Whitman’s campaign to be governor of California and, after she lost, helped her get a job at Kleiner Perkins.

Whitman talked to Andreessen, another friend. He told her he thought she’d be an excellent addition to the technology committee and he praised Apotheker as a strategic thinker. To Whitman, the venture sounded interesting and fun. “This is probably a well-run company,” she thought. “It’s 12 minutes from my house. What could go wrong?”

Plenty was still going wrong at HP in the spring of 2011. On May 4, Apotheker composed a grim e-mail to his top executives. The third quarter was going to be “another tough” one, he wrote. “We must watch every penny and minimize all hiring.” Two weeks later the memo turned up in a Bloomberg News article. The memo’s grim tone contradicted the sunny message that Apotheker was conveying to Wall Street. The leak forced HP to accelerate its quarterly earnings release, which included news of another pullback of revenue projections. HP shares plummeted. Apotheker was incensed by the leak.

He had wandered into a snake pit. Hurd had fed the rivalries of top executives, claiming that competition and “dynamic tension” inspired better performance. Sometimes Hurd gave multiple executives the same assignment. Everyone knew who was in Hurd’s doghouse and pounced on them. He had ridden Vyomesh Joshi, the head of the printer group, particularly hard.

Perhaps because they were used to being dominated by Hurd, few in HP’s senior ranks would challenge the CEO directly. Consider Apotheker’s attempt, earlier that year, to find a catchy phrase that could define HP. He settled on a head-scratcher: “Everybody on.” Instead of opposing the idea, almost every executive told Apotheker it was a great slogan (with at least one whispering behind his back that it was horrible). Only Joshi was willing to speak up. “I don’t get this,” he told Apotheker when the slogan was unveiled at a meeting. Joshi earned the CEO’s wrath. The campaign launched — and promptly bombed. As one tech blog headline described the debut, HP’S “EVERYBODY ON” AD GOES TO THE GRAMMYS, CAUSES NATIONWIDE CRINGING.

It didn’t help that HP’s divisions were run as separate entities, each with its own marketing, public relations, and finance teams, and each was held responsible for its own performance. There was little incentive to cooperate. It sometimes seemed as if the printer and computer teams were from separate companies. (This could lead to ludicrous consequences. Some HP PCs didn’t even have software that would automatically allow them to “talk” to an HP printer.)

Hurd had managed to hold it together. He had an encyclopedic mastery of numbers and details; he knew which functionary to call deep inside the organization to make things happen. He was an energetic and forceful commander — somewhere between Gen. George Patton and the Robert Duvall character in Apocalypse Now. You may not have liked the guy, but by God, you were going to follow his orders.

Apotheker, by contrast, was an outsider with a foreign accent. He carried himself more like a professor of German philosophy. He lacked Hurd’s stamina, nodding off the first time he met HP’s senior executive team as CEO. Apothecker chuckled at his own droll putdowns of California wines, but nobody else seemed to laugh. And he had a distinctive blend of arrogance — a certainty that the board applauded his every move — combined with a fear that some executives were trying to undermine him.

Apotheker seemed not to trust longstanding HP executives such as Lesjak, Holston, and Bradley, who he had allowed to stay on. They returned the sentiment. And Apotheker alienated some HP veterans by bringing in a coterie of SAP executives who, one HP source says, were “abnormally deferential.” One of them, Marty Homlish, who had been SAP’s marketing chief and Apotheker’s right hand in the Oracle fight, took over marketing at HP. Homlish routinely addressed the CEO as “my lord.” It was meant to be funny, but colleagues were taken aback. The practice only accentuated Apotheker’s outsider aura.

Apotheker was failing to unite his executives, but he thought he could count on Lane, who had told Apotheker he would manage the board while the CEO focused on running the business. Apotheker considered Lane a friend. The two men had gotten to know each other decades earlier when, long before either had developed an antipathy for Oracle, Apotheker had taken a hiatus from SAP and consulted for Ellison’s company.

There were reasons for optimism. HP had decided to increase its investment in the tablet that had come with the Palm acquisition. It was set to go on sale in July, and the webOS software would be used to launch a new line of smartphones, PCs, and printers. No one expected to dethrone the iPad any time soon. But HP’s new tablet would give the company a presence in that market.

In May 2011, Apotheker began in-depth discussions with HP’s board on his two other initiatives: a software acquisition and the plan to spin off its PC business. Between May 25 and July 21, he held repeated strategy sessions with the board and various committees. But before they could make any decisions, calamity struck: HP’s tablet was an unmitigated disaster. It went on sale only to be panned as ungainly, slow, and burdened with a subpar battery. The webOS software performed well. But Apotheker was galled by the failure of HP’s hardware. The tech titan had taken a big swing at the hottest new device in the market and whiffed. The failure was so complete that HP began thinking about pulling the tablet entirely.

The disaster added urgency to Apotheker’s strategic plans. He had wanted to go big in software; he had a British data company, Autonomy, he wanted to buy. It would be a perfect complement to HP’s portfolio, Apotheker argued, because its software — a sort of Google GOOG for corporations that can search voicemail, texts, and video — would bolster HP’s software and services offerings.

Apotheker appeared before the board and conceded that it was a tricky deal, one that might hurt HP’s stock price in the short run. But then the usually formal CEO made an emotional personal appeal. “This company is a burning platform,” he told the directors. HP needed a new vision. He concluded: “I cannot do this alone. I need your support. We’re going to have to hold hands and go through this together.”

It was a stirring presentation, but it was followed by an even more dramatic moment that blindsided Apotheker. He knew that the CFO, Lesjak, opposed the deal. She had told him the price, around 11 times revenue, was too rich. Comparable companies were selling for three times revenue, according to investment bank Software Equity Group. He’d countered that Autonomy’s profitability more than justified the price. The two had discussed it privately.

But then, with no warning to Apotheker, Lesjak made an impassioned case against the acquisition before the board. “I can’t support it,” she told the directors, according to a person who was present. “I don’t think it’s a good idea. I don’t think we’re ready. I think it’s too expensive. I’m putting a line down. This is not in the best interests of the company.” Directors were shaken. Lesjak was considered a voice of sobriety, and here she was on the verge of insubordination, directly resisting a key element of her boss’ strategy.

As the debate over Autonomy unfolded, Apotheker and the board tackled an even bigger decision, one that went to the very heart of what HP is all about: Should they jettison the company’s $41-billion-in-sales PC division? Unfortunately, the process by which that decision was made would reflect everything wrong with HP in general and the Apotheker/Lane regime in particular. It was rushed and cursory, first dramatically conclusive — and then uncertain.

In July the board had set up a five-member committee to study the options for the PC division. The committee, which included Babbio, former Lucent CEO Pat Russo, and Ray Lane, held all of two meetings. They didn’t even consult Bradley, the head of the division in question. The directors were afraid he would leak the news, so they excluded him.

It was a huge decision, but the board quickly agreed that the spinoff was a good idea. The division’s margins were 6% and shrinking. The iPad was eating into the growth of the PC market, raising questions about its future. Apotheker and the directors thought HP could spin off the division and use the cash better elsewhere. Everyone recalled that IBM’s sale of its PC division had been a crucial step in its transformation.

But even when the board was decisive, the company couldn’t avoid tripping over itself. Lesjak and general counsel Holston argued against announcing definitive plans to unload the division; it might expose HP to shareholder litigation if the plan didn’t work out. Because of the fear of leaks, they said, Lane and Babbio’s committee hadn’t been able to do enough due diligence to assess these impacts. Lesjak and Holston pushed for a weaker statement that HP was considering a spinoff. In part because of the credibility Lesjak had on Wall Street, their voices carried the day.

The activity was frenzied inside HP’s executive suites. Apotheker and his top aides were shuttling between groups working on the different initiatives. The CEO himself seemed to be feeling the pressure. After a PR operative told the board that the announcement would be a disaster — there were too many things being trumpeted at the same time and the mealy-mouthed decision to “explore” a PC spinoff would be badly received — Apotheker flew into a rage. He stalked back to his office, violently shoving a chair out of his way, and pounded his desk.

But for all the tension, and the challenges to Apotheker’s plans, Lane had marshaled support on the board. The directors were unanimous. On Aug. 18, they approved the Autonomy deal and the plans to explore a PC spinoff. With an investor’s call scheduled for later that day, Lane e-mailed Apotheker some tweaks to the final script, which the chairman pronounced “good.”

HP’S announcement on Aug. 18, 2011, rocked the tech world. It contained three big pieces of news: the Autonomy deal, the possible PC spinoff, and word that HP was officially ending its multibillion-dollar tablet initiative. For good measure, the company lowered its earnings projections for the year. Apotheker told Wall Street analysts on a conference call that he felt investors’ pain, “but as CEO, I believe in transparency about what we are facing and [the need to] be clear on the decisive things we are doing now about it.” He and his lieutenants used variations of the word “transformation” 20 times.

After the call, Lane received a congratulatory e-mail from Kleiner Perkins partner John Doerr, praising the big, bold moves. Replied Lane in a reference to HP’s founders, “I actually think Bill and Dave would be proud.” Inside HP’s headquarters, champagne corks were popped.

Outside, the reaction was dire. Customers, investors, employees, and the financial press were all aghast. HP, it seemed, had gone mad. Shares plunged 20% the following day.

Apotheker learned of his firing in the press — then was told he’d lost the confidence of the board and his top lieutenants.

At first Lane stood beside Apotheker. “I don’t know a single technology company that has succeeded without changing its strategy,” he told journalists. But Lane (who declined to be interviewed) quickly began backing away. PC customers were bailing out. Investors were furious that HP was making a major acquisition after Apotheker had said they wouldn’t. Behind the scenes, Lane began maneuvering. In mid-September, the CEO failed to appear as scheduled at a tech conference. Lane showed up instead. Apotheker was about to be toppled.

Not for the first time, the news reached the press before the official announcement. On Sept. 22, Apotheker read that he was being fired and replaced by Whitman. He was flabbergasted. In a meeting that morning, Lane told him that he had lost the support of the board and every single member of the executive team — including former SAP loyalists such as Homlish. Before the board, Apotheker was subdued, dignified and resigned. But he was incensed. He had fully consulted with the board on everything, he told friends. He’d trusted Lane to make the board a functioning one, but instead Lane had turned it against him.

Lane distanced himself from the disaster, blaming Apotheker. The man who’d been proud of HP’s bold moves was now running as fast as he could from the word “transformation.” It had, Lane said in a conference call with investors, “been stricken from our language.” Asked in a CNBC interview whether the board bore responsibility for HP’s chaos, Lane reacted defensively. “I’m going to give you an answer right from my heart, okay? In January, I added five board members to this board. This is not the board that was around for pretexting. This is not the board that fired Mark Hurd. It’s just like open season to write about this board. It’s not this board. This board did not select Léo, okay?”

If Meg Whitman had any illusions about the challenges she faces, they were eliminated before she even made it inside HP’s office. Driving her Ford Escape to HP’s headquarters, she was directed to a special executive committee parking lot that was blocked by a gate and an imposing green fence topped with barbed wire. Whitman stared in disbelief. In her mind there shouldn’t have even been an executive parking lot at HP, much less one with concertina wire befitting a military installation or jail.

The fence was a stark reminder of the gulf that had grown between senior leaders and employees. Whitman had it torn out. She also eliminated the executive committee suites and moved the top brass to cubicles. Now, even Whitman has to compete for parking spots and walk in the public entrance like everyone else. Gone also are stays at swank hotels in favor of more modest accommodations.

“It’s back to Bill and Dave’s culture,” Whitman says, acknowledging that these moves were the easy ones. “Symbolism is important. I learned that in politics.”

Whitman has moved decisively to make changes in the executive committee. She forced out longtime printer head Joshi, merging his unit into the PC group, and general counsel Holston. Chief strategist Shane Robison retired.

Still, Whitman has already had a few stumbles. HP’s first-quarter results were even worse than expected, sending shares skidding. In a call to discuss those earnings, she allowed a touch of hubris to seep into her assertion that she will turn HP around. “I’ve done this a number of times in my career,” she said. “It’s what great business leaders do.”

For his part, Lane shows no signs of fading into the background. In their first joint interview on CNBC on the day after Whitman was named CEO, Lane dominated the interview, at times filibustering Whitman. He has since told employees he is ready to “take Meg’s training wheels off.”

For now, anyway, Whitman and Lane’s strategy boils down to do what we do — better. One of Whitman’s first announcements was to confirm that HP is keeping its PC group. It couldn’t be spun out, HP argued, without inflicting significant damage on HP’s other businesses. Meanwhile HP’s revenues, margins, and cash position continue to deteriorate. The spate of acquisitions, chief among them the Autonomy deal, means the company has little money for new moves. In coming months, tens of thousands of employees are expected to be laid off.

Whitman faces a daunting, though surmountable, challenge in devising a strategy that will put HP on the path to recovery or reinvention. But that’s only part of her task. Exorcising HP’s demons — in its boardroom, in its executive suites, and among thousands of dispirited engineers and staffers — will be another matter entirely.