The 'Lunch in the Sky' exhibit by International Business Machines Corp. hangs suspended in the sky at the CeBIT 2018 tech fair in Hanover, Germany, on Monday, June 11, 2018.

IBM's stock price will rally due to strong demand in key technology growth markets, according to UBS.

The firm raised its rating to buy from neutral for the company, predicting IBM will generate earnings above expectations next year.

"We think sustainable growth for IBM is on the horizon," analyst John Roy said in a note to clients Tuesday. "The mainframe cycle will be ending and the FX headwinds are likely to hurt the top-line optics, but we believe this is priced in. IBM is operating better but we believe the multiple could expand as it beats expectations on Analytics and Cloud."

IBM shares rose 1.8 percent Wednesday.

The analyst said his firm's survey of IT executives reveals strong demand for IBM services, artificial intelligence and cloud offerings. He noted that IBM's cloud computing business, which competes with Amazon Web Services, grew 22 percent in sales last year to $7.2 billion.

Roy increased his price target to $180 from $160 for IBM shares, representing 21 percent upside to Tuesday's close.

The analyst estimates IBM will generate 2019 earnings per share of $14.25 versus the $14.04 Wall Street consensus.

IBM shares are underperforming the market this year. Its stock is down 3 percent year to date through Tuesday versus the S&P 500's 9 percent return.

— CNBC's Michael Bloom contributed to this story.