Hewlett-Packard Co is close to a deal to buy British software company Autonomy for $10 billion and will announce on Thursday a long-rumored spinoff of its PC division, the world's largest, two sources familiar with the company's plans said.

Shares in HP, a storied Silicon Valley icon that dominates the personal computing industry, reversed course to gain more than 3 percent when the news was first reported by Bloomberg, citing unnamed sources. But the stock quickly backtracked and was down more than 4 percent at $30 in afternoon trade.

A spinoff of HP's PC arm would confirm speculation that has swirled for months that HP was no longer keen on keeping a business struggling with low growth and single-digit margins.

The company plans to announce the spinoff after the market's close, the sources told Reuters on condition of anonymity.

HP and Autonomy were not available for comment.

HP Chief Executive Leo Apotheker, a former chief of European software giant SAP AG, had been expected to drive an expansion of the company's relatively small but very profitable software division -- including through major acquisitions.

Cambridge-based Autonomy counts Procter & Gamble Co among a long list of major corporate customers that use its software to search and organize unstructured data like emails. Last month, it posted a 16 percent jump in quarterly sales-driven demand for Internet-based cloud computing.

(Additional reporting by Victoria Howley in London and Edwin Chan in Los Angeles; Editing by Lisa Von Ahn and Richard Chang)