(Reuters) - International Business Machines Corp IBM.N on Wednesday reported second-quarter profit and revenue that topped analysts' expectations as it benefited from growth in higher-margin businesses including cybersecurity and cloud computing.

FILE PHOTO: The logo for IBM is displayed on a screen on the floor of the New York Stock Exchange (NYSE) in New York, U.S., June 27, 2018. REUTERS/Brendan McDermid/File Photo

Under Chief Executive Officer Ginni Rometty, IBM has been focusing on an array of new technologies ranging from artificial intelligence to cloud computing as it tries to offset weakness in its legacy business of selling hardware and software.

The newer businesses, which are spread across its various divisions, have been bundled into what the company calls “strategic imperatives”.

Revenue from these businesses grew 15 percent to $10.1 billion in the second quarter, accounting for more than half of the company’s total revenue.

IBM Chief Financial Officer James Kavanaugh said the company’s investments to reposition itself have been paying off.

“We accelerated our growth, really capitalizing on these emerging high value areas,” Kavanaugh told Reuters.

Overall revenue rose nearly 4 percent to $20 billion, beating analysts’ average estimate of $19.85 billion, according to Thomson Reuters I/B/E/S.

The company’s revenue has now risen for three straight quarters after falling for nearly six years.

Operating gross profit margin in the quarter slipped to 46.5 percent from 47.1 percent.

“One of the key components was as-a-service growth ... and as that scales through, you’re starting to see margin expansion shine. Gross margin closed the gap,” CFRA Research analyst David Holt said.

Net income rose to $2.4 billion, or $2.61 per share, in the quarter ended June 30 from $2.33 billion, or $2.48 per share, a year earlier.

Excluding items, IBM earned $3.08 per share, beating analysts’ average expectation of $3.04 per share.

Shares of the Armonk, New York-based company rose about 2.5 percent to $148.13 in trading after the bell.