The former gubernatorial candidate is struggling to revive the troubled tech giant, a process that could take years

SAN FRANCISCO — Had things gone differently, Meg Whitman might today be governor of California, fighting to turn around one of the country's most financially troubled state governments.

Instead, having lost her bid for that office in November 2010, she finds herself head of Hewlett-Packard Co., struggling to fix one of the high-tech industry's most troubled giants.

Save HP or California. It's hard to say which is the tougher job.

It sometimes seems as if just about everything that could go wrong at HP has gone wrong in recent years. HP went from being a high-tech juggernaut three years earlier to a company in steep decline, a trajectory that Whitman inherited in September 2011 and so far has been able to slow, but not stop.

"It's a huge company," said Jayson Noland, an analyst at R.W. Baird & Co. "And they are not clicking at all right now."

Just when it seemed every possible shoe had dropped, HP announced in November that it had uncovered what it contended was massive accounting fraud at Autonomy, a British software company it acquired in 2011.

In turning over evidence to U.S. and British regulators, Whitman has triggered a war of words with Autonomy's brash founder and a fresh round of lawsuits from shareholders who have watched their investment continue to hit once unthinkable lows.

Even as the unfolding legal drama threatens to become a distraction, Whitman insists that she has every intention of staying at HP's helm for the next few years, which is what she believes it will take to restore this Silicon Valley icon to greatness.

"I knew this turnaround was not a one- to two-year program," Whitman said. "Even before I took this job, I knew it was a bigger undertaking."

Sitting in a conference room at HP's Palo Alto headquarters during a recent interview, Whitman seemed to wear lightly the burden of representing the hopes that better days lie ahead for the company's 331,800 employees. She managed to laugh and smile at times while also delivering detailed responses displaying a technical grasp of HP's massive product line and a staunch defense of her decisions and vision for the company.

For the moment, Whitman, 56, also seems to be remarkably comfortable sitting in a place she could have never imagined being two years ago, after the state's voters delivered an underwhelming verdict on her quest to become governor.

"It was not part of my plan," she said. "I said many times my last CEO job was going to be EBay."

Despite spending millions of dollars on her failed gubernatorial campaign, Whitman's stint as chief executive of EBay Inc. from 1998 to 2008 had left her wealthy, and there remained plenty of goodwill toward her in Silicon Valley. She seemed headed toward the role of elder stateswoman, becoming a part-time advisor at the prestigious venture firm Kleiner Perkins Caufield & Byers and joining corporate boards such as Procter & Gamble and Zipcar.

In January 2011, Whitman was asked to join the board at HP. Nine months later, the company fired Chief Executive Leo Apotheker. He had been running HP for less than 11 months following the departure of former CEO Mark Hurd, who resigned after a female contract employee accused him of sexual harassment.

Seeking a steadier hand, the board turned to Whitman.

"I thought I could make a difference," Whitman said. "But I thought about it long and hard, because it was a big commitment."

The list of problems she inherited was daunting.

Amid the CEO turmoil, HP, one of the largest makers of personal computers in the world, was forced to abandon its TouchPad tablet — developed in response to Apple Inc.'s iPad — when the device failed to catch on with consumers. HP's hardware sales suffered as customers shifted to cloud-based services. And although it had made some massive acquisitions, such as Palm and EDS, both companies experienced problems that resulted in billions of dollars in write-downs.

Then HP faced a backlash over its announcements in August 2011 that it was considering selling its PC business and that it was buying Autonomy for the steep price of $11 billion, controversies that helped lead to Apotheker's ouster a month later.

What happened after Whitman took charge at HP seemed remarkable to those who followed her gubernatorial campaign. Criticized for being aloof and remote during her run for governor, a narrative she says was untrue, Whitman was suddenly everywhere — talking on CNBC, granting numerous interviews. She appeared relaxed, personable, confident. Here, suddenly, was the real Meg Whitman that her friends and supporters insisted that California voters didn't get a chance to see during the campaign.

"A company like HP needs a leader," Whitman said in the interview. "And it needs someone who can be the face of the company."