Shares in retail giant Amazon soared 18% in after-hours trading on Thursday, making it the most valuable retail company in the world, after the company announced an unexpected profit and a sharp rise in sales for its latest quarter.

Amazon at 20: what has the online giant ever done for retail? Read more

The share price hike added more than $7bn to the $34.7bn fortune of founder Jeff Bezos in less than 45 minutes.

As the shares climbed, they surpassed those of Walmart, making Amazon the highest-valued company in retail in the world. An hour after it announced its earnings, Amazon was valued at approximately $270bn while Walmart had closed with a valuation of $233bn.

For the second quarter ending on 30 June, Amazon reported a $92m profit and gains of $0.19 per share instead of the $0.13 loss Wall Street analysts had expected. While analysts expected the company to do better than it did a year ago, when it posted a loss of $126m, they had expected the revenue growth to be closer to 16% with revenue reaching $22.4bn. Instead, revenue rose to $23.19bn.

Amazon had a lot to celebrate this quarter, according to Bezos, founder and CEO of Amazon.com. The better-than-expected results came just a week after the company celebrated its 20th anniversary.

“The teams at Amazon have been working hard for customers,” he said on Thursday. “We unveiled Amazon Business, opened Amazon Mexico, launched Prime free same-day, rolled out our ninth Prime Now city, broke our Black Friday record with the first-ever Prime Day, received 11 Emmy nominations for Transparent, debuted six new kids’ pilots, brought Echo to general availability, introduced the Alexa Skills Kit and Alexa Voice Service, opened FBA Small and Light, continued to double down on our fastest-growing geography – India, launched 350 significant AWS [Amazon Web Services] features and services so far this year (ahead of last year’s pace), introduced AWS Educate, and entered into agreements for new solar and wind farms – enough to exceed our 2016 goal of 40% renewable energy.”

Leading authors call for government probe of Amazon's 'damaging' power Read more

Much of the growth reported this quarter can be attributed to the company’s Amazon Web Service, AWS, which is the company’s collection of remote cloud computing services.

This is the second quarter since Amazon began disclosing revenue and operating profit for AWS and for the second time, the growth for this division surprised Wall Street analysts. In the first quarter, AWS revenue was up 49% from 2014. This time around, the revenue for AWS rose 81% from a year ago, reaching $1.82bn by 30 June.

Thomas Szkutak, Amazon CFO, also pointed out that Amazon is the largest AWS customer.

When asked whether the fact that the Fire phone was not mentioned by name in Thursday’s release meant that analysts should “chalk it up to a learning experience”, Szkutak said the company does not comment on a roadmap of products and has nothing to offer. He did, however, add that the company learns from everything it does and values feedback from its customers.

It has not all been smooth sailing for Amazon.

At the beginning of this month, the company informed writers whose works are available through Kindle Owners’ Lending Library that they will not be paid per download but instead for page read at the rate of $0.006 per page. Up until then, authors were paid $1.30 per download. This means that only authors whose books are 220 pages long or longer and are read from cover to cover will make the same or more in the future.

About two weeks later, leading authors including Malcolm Gladwell, Ursula Le Guin, Michael Chabon and Ann Patchett penned a letter to the US Department of Justice demanding that it investigate the retailer’s “power over the book market”.