Technology giant Hewlett-Packard announced Thursday that it was naming former eBay head Meg Whitman as its new chief executive in the latest plot twist for the storied Silicon Valley firm, which has been beset by scandals and turnover at the top.

Whitman succeeds Leo Apotheker, who lasted less than a year in the job. Whitman, famed for her work leading eBay and her failed run for California governor in 2010, takes over as the company tries to reinvent itself — away from selling traditional computers and printers to consumers, to pitching technology services and products to businesses.

“We are fortunate to have someone of Meg Whitman’s caliber and experience step up to lead HP,” Ray Lane, who also shifted from non-executive to executive chairman of HP’s board of directors, said in a statement. “We are at a critical moment. . . . Meg is a technology visionary with a proven track record of execution.”

HP has had seven chief executives since 1999. Apotheker’s predecessor, Mark Hurd, stepped down abruptly last year after allegations surfaced that he had sexually harassed a contractor for the company. Hurd followed Carly Fiorina, who was ousted after her ambitious and controversial plan to merge the company with computer maker Compaq.

In another scandal, former chairman Patty Dunn resigned in 2006 after it emerged that HP had hired investigators to spy on its own board members by “pretexting,” or posing as other people to obtain phone records.

The controversies has distracted the company as it has spent the past decade searching for its identity amid massive change in the tech industry. Fiorina’s acquisition of Compaq sent the company deep into the PC business.

HP is now considering spinning off that business because of its lower profit margins. Whitman said in a conference call with analysts on Thursday that the company would make a final decision by the end of the year.

Whitman, who has been a member of HP’s board for the past eight months, is known for her star power in Silicon Valley. During her tenure at eBay, she was one of the most powerful women in the business world. Now she joins an iconic firm founded in 1939 by Stanford University classmates Bill Hewlett and Dave Packard in a garage in Palo Alto, Calif.

“I am honored and excited to lead HP. I believe HP matters — it matters to Silicon Valley, California, the country and the world,” Whitman said in a statement.

Some analysts questioned whether her work at eBay, which was focused on consumers rather than businesses, has adequately prepared her to take the helm of HP.

“Our concern would be that she doesn’t have a lot of enterprise and technology experience,” said Jayson Noland, a tech analyst at Robert W. Baird & Co. “She’s not the most obvious choice to me.”

During the call with analysts, Lane said the board decided to replace Apotheker because he wasn’t executing the company’s strategy. The company’s stock is down almost 46 percent for the year. By comparison, the Standard & Poor’s 500-stock index has fallen roughly 10 percent.

Many have accused HP’s board of being responsible for all the drama surrounding the company. On Thursday, analysts wondered whether the board was bungling another major decision, especially because it had picked Apotheker only recently.

“This is not the board that was around for pretexting. This is not the board that fired Mark Hurd,” Lane said during the call, noting that many of those members had been replaced. Indeed, five new members have joined since January; all of them joined after the decision to hire Apotheker.

“This company has been through a lot,” said Whitman, also on the call. “There is no question about it.”