IBM surprised markets by sharply raising its full-year earnings forecast as its growing software and services businesses boosted profit margins, lifting its shares in after-hours trade.

Stock in the world's largest technology services firm rose as much as 3 percent, building on gains of more than 3 percent in the regular session, as the company's outlook and higher-than-expected quarterly earnings gave investors hope that the worst of the technology downturn may be over.

Kim Caughey, senior analyst at Fort Pitt Capital Group, was impressed by the outlook and earnings despite the lower revenue.

This, combined with Intel's results, is pushing me to be more optimistic. Seeing they made it on the bottom line, and were pretty darned close on the top line, it gives me confidence looking at technology in general.

International Business Machines Corp said it now expects 2009 earnings of at least $9.70 per share, up from its previous outlook of $9.20.

The upbeat results added to the market's optimism following leading chipmaker Intel Corp's stronger-than-expected earnings and outlook announcement this week.

Analysts said IBM's higher outlook took the disappointment out of its lower-than-expected second-quarter revenue, which fell 13 percent to $23.3 billion. The market's average forecast had been for $23.5 billion, according to Reuters Estimates.

Net profit for the quarter rose to $3.1 billion from $2.8 billion in the year-ago quarter. Profit per share rose to $2.32 from $1.97, much higher than the average Wall Street forecast of $2.01 per share, according to Reuters Estimates.

In an unpleasant economic and financial world, these are incredible results, said Mike Holland, chairman of investment firm Holland & Co.

PROFITABILITY

IBM has fared better than many other technology companies amid the downturn, helped by its growing focus on profitable software and services like outsourcing and technology support, rather than increasingly commoditized hardware.

Its gross profit margin rose to 45.5 percent from 43.2 percent a year earlier.

Chief Executive Samuel Palmisano said the results underscored how the company's transformation continued to reap benefits.

We are well ahead of pace for our 2010 roadmap of $10 to $11 per share, he said.

Chief Financial Officer Mark Loughridge said economic conditions remained tough and held off of sounding an all-clear, but said he saw further room for the company to improve its profitability.

He also said he expects the U.S. government's stimulus plans to begin encouraging customers' discretionary spending, and forecast a weaker dollar to provide tailwind.

IBM rose to $112.40 in extended trading, after closing up $3.42, or 3.2 percent, at $110.64 on the New York Stock Exchange.

(Reporting by Ritsuko Ando; Additional reporting by Jim Finkle and Robert MacMillan; Editing by Edwin Chan and Richard Chang)