Amazon shares surged nearly 9% in after hours trading after the company reported stronger than expected second quarter results, driven by accelerating cloud and artificial intelligence demand.

Amazon reported net sales of $200.6 billion, up 20% from $167.7 billion a year earlier. Operating income rose 43% to $27.5 billion from $19.2 billion.

Amazon Web Services generated $42.2 billion in revenue, up 37% from the previous year and marking its fastest growth in 18 quarters. The result exceeded analysts’ expectations of approximately $40.5 billion and growth of around 31%.

AWS operating income climbed 64% to $16.6 billion, giving the cloud division an operating margin of 39.4%. AWS accounted for about 21% of Amazon’s total revenue but generated more than 60% of its operating income during the quarter.

Amazon said its AWS artificial intelligence business and custom chip business each surpassed annual revenue run rates of $25 billion, with both growing at triple digit rates.