International Business Machines last night reported second-quarter profit and revenue that topped analysts' expectations.

IBM said it was benefitting from growth in higher-margin businesses including cybersecurity and cloud computing. 

Under chief executive 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% to $10.1 billion in the second quarter, accounting for more than half of the company's total revenue. 

IBM's 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% to $20 billion, beating analysts' average estimate of $19.85 billion, according to Thomson Reuters. 

The company's revenue has now risen for three quarters in a row after falling for nearly six years.

IBM said its operating gross profit margin in the quarter slipped to 46.5% from 47.1%.

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.