HP's strong printing and imaging division and progress in cutting costs following the merger with Compaq contributed to profits of $390m, despite weak demand for its PC, server and storage products.
The company posted earnings of $18bn (£11.5bn) for the fourth quarter, which ended 31 October, compared with a combined revenue of $18.2bn from HP and Compaq in the same quarter last year.
"I am pleased with our performance when you consider the continued weakness of the IT market," said HP chairman and chief executive officer Carly Fiorina.
The company said it had cut costs by $651m as a result of the Compaq merger, some 30% ahead of target.
The company also announced it would lay off another 1,100 workers as a result of the merger, in addition to the 16,800 already announced. Most of the extra job cuts will be made in Japan.
The printing and imaging business churned out $5.6bn in revenue for the fourth quarter, a 12% increase year on year.
HP's enterprise business, which includes servers, software and storage products, saw revenue decline 5% on the same quarter last year, to $4.1bn and an operating loss of $152m. HP's high-end Superdome Unix servers provided a bright spot, with 63% revenue growth from a year ago, although its Unix business stayed flat overall.
Despite HP's efforts to bolster its software line with new products, revenue from software tumbled 15% year on year.
The company's services business - a key driver for its merger with Compaq -- also fell in the quarter. It declined 3% year on year to $3.1bn in revenue.