By MAE ANDERSON
AP Tech Writer

NEW YORK (AP) _ Investors helped Amazon celebrate its 20th birthday, pushing the online retailer’s stock up 17 percent in aftermarket trading Thursday after it reported a surprise second-quarter profit.

If the jump holds in Friday trading, Amazon’s stock-market value could surpass that of its longtime retail rival Wal-Mart Stores Inc., signaling a sea change in the U.S. retail landscape.

Amazon, which turned 20 on July 16, credited the profit to continued strength of its cloud-computing business and strong revenue growth both domestically and abroad. That came as it held costs for marketing and package delivery in check.

Seattle-based Amazon has held a long-time strategy of investing the money it earns back into the company, resulting in quarterly losses or thin profits. But helped by surging revenue, it has begun to turn a bigger profit more frequently, although results vary quarter to quarter. In the first quarter, for example, Amazon reported a loss, though it was smaller than expected.

In a call with analysts, new Amazon CFO Brian Olsavsky said the company would continue to look for ways to keep costs in check while at the same time investing in “things that we think are big and important.”

Amazon got a boost in revenue from Amazon Web Services, a suite of products and services offered to businesses by way of the “cloud,” or remote servers that enable users to access applications on any machine with an Internet connection. Revenue from that business climbed 81 percent to $1.82 billion. Amazon only began breaking out results from that business during the first quarter.

Amazon also said its $99-a-year Prime loyalty program helped drive growth during the quarter. The company won’t say how many Prime members it has, but it’s estimated to be as many as 40 million, and Prime members typically spend more than other shoppers.

Last week, Amazon offered sales for one day to members only. Amazon said the Prime Day promotion helped drive 18 percent more sales than last year’s Black Friday _ typically the busiest day in retail. The company also said it got hundreds of thousands of new signups from its Prime Day promotion. The second-quarter results do not include revenue from that day.

In the three months ending June 30, Amazon’s net income was $92 million, or 19 cents per share, compared with a loss of $126 million, or 27 cents per share, a year earlier. The results surpassed Wall Street expectations. The average estimate of 15 analysts surveyed by Zacks Investment Research was for a loss of 15 cents per share.

The online retailer posted revenue up 20 percent to $23.2 billion in the period, also beating Street forecasts. Fifteen analysts surveyed by Zacks expected $22.3 billion.

For the current quarter ending in September, Amazon said it expects revenue in the range of $23.3 billion to $25.5 billion. Analysts surveyed by Zacks had expected revenue of $23.8 billion.

Amazon shares have climbed 55 percent since the beginning of the year. They closed Thursday’s regular trading session at $482.18, an increase of 35 percent in the last 12 months. After the earnings came out, shares jumped $85.54 to $567.72 in aftermarket trading.

At Thursday’s closing price, Amazon’s market value totaled about $224.5 billion. But factoring in the surge aftermarket, Amazon’s value would be worth about $265 billion.

Wal-Mart Stores Inc.’s market cap was $233.5 billion at close. But Wal-Mart is still the world’s biggest retailer by far measured by total revenue.

Last month Facebook became more highly valued than the world’s largest retailer, knocking it out of the top 10 list of the highest-valued companies in the Standard & Poor’s 500 index.

A company’s market value is calculated by multiplying the number of shares of stock it has in circulation by the current price of one share.