Carly Fiorina is one of America's most successful businesswomen
Ms Fiorina, one of America's most powerful businesswomen, said she was leaving after a dispute with the company's board over future strategy.
The company has struggled to remain profitable since Ms Fiorina pushed through a controversial merger with rival Compaq in 2002.
Investors cheered Ms Fiorina's exit, HP's shares rising 10%.
They stayed sharply higher all day, closing up nearly 7%.
Chief financial officer Robert Wayman has replaced Ms Fiorina temporarily.
Under pressure
Ms Fiorina, who headed HP for six years, has been under pressure in recent months as the firm's profits failed to meet market expectations.
While I regret the board and I have differences about how to execute Hewlett-Packard's strategy, I respect their decision
Carly Fiorina
Ms Fiorina's life and times
Earlier this month, Ms Fiorina denied newspaper reports that she had been sidelined and said her relationship with the board remained excellent.
Ms Fiorina oversaw a diversification of HP's activities away from of its core printer and imaging business into the highly competitive personal computer market.
She pushed through the acquisition of Compaq Computer in 2002 despite strong opposition from fellow directors and shareholders.
"Carly Fiorina came to HP to revitalise and reinvigorate the company," Patricia Dunn, HP's non-executive chairman, said in a statement.
"We thank Carly for her significant leadership over the past six years as we look forward to accelerating execution of the company's strategy."
Change of direction?
"While I regret the board and I have differences about how to execute Hewlett-Packard's strategy, I respect their decision," Ms Fiorina said.
Analysts said Ms Fiorina's abrupt departure marked a change of strategy for the company.
"I think Fiorina very much personified the strategy that the company had embraced in the past several years," said Peter Sorrentino, chief investment officer at Bartlett & Co.
"With her departure, it signals to me that they have elected to take a whole new course of action and that they have decided that this was not a strategy she was in support of."
New York - Carly Fiorina was ousted by the board of directors of HP yesterday, much to the delight of Wall Street. Ms Fiorina's resignation was the result of a disagreement with the board over the future of the company. Often cited as America's most powerful businesswoman, Ms Fiorina presided over the multi-billion dollar merger between Hewlett Packard and Compaq Computers in 2002. 

The move comes after several months of intense speculation about her future with the company. Having promised billions in annual savings to the company from the 2002 merger, the combined company failed to keep pace with competitors such as Dell, or to deliver any significant increases in profits, particularly in the personal computer market. A recent investigation by Fortune magazine highlighted the fact that the firm's highly profitable printer business supported the lower-margin computer business. 

After the announcement, HP shares surged 10% on Wall Street against a generally poor performance by the major indices.