Amazon.com Inc on Thursday reported a profit near $2 billion, the largest in its history, as the online retailer drew millions of new customers to its Prime fast-shipping club for the holiday season and as changes to U.S. tax law added to its bottom line.

Shares rose more than 6 percent in extended trading, after previously closing down 4 percent on the Nasdaq.

Seattle-based Amazon is using fast shipping, television shows exclusive to its website and forays into new technology, such as its voice-controlled Alexa devices, to attract high-spending Prime members. Amazon said price cuts at Whole Foods Market, which it acquired for $13.7 billion last year, are helping it win grocery sales, too.

The world’s largest online retailer said net income more than doubled to $1.86 billion, or $3.75 per share in the fourth quarter ended Dec. 31. Its profit received a provisional $789 million boost from the U.S. Republican tax bill passed in December. Analysts on average were expecting just $1.85 per share, according to Thomson Reuters I/B/E/S. (http://tmsnrt.rs/24gibla)

“This was another blow-out quarter for Amazon,” said GBH Insights analyst Daniel Ives. “The retail strength was eye-popping as the company had a banner holiday season and looked to capture roughly 50 percent of all e-commerce holiday season sales.”

As expected, the period running from before the U.S. Thanksgiving holiday through New Years was Amazon’s biggest-ever by revenue. Sales rose 38 percent to $60.5 billion in the quarter, beating estimates.

The company’s fast delivery, like its two-hour Prime Now service, has helped win over holiday shoppers eager to avoid the crowds of big box retailers. Prime saw more than 4 million sign-ups in one week alone last quarter, and revenue from subscription fees grew 49 percent to $3.2 billion, Amazon said.

That figure is expected to rise this quarter in part because the company recently raised the fee for month-to-month Prime plans, affecting some 30 percent of subscribers, according to analysts at Cowen & Co. Some 60 million, or close to half of all U.S. households, are estimated to have Prime subscriptions.

Perhaps the surprise star of the past quarter was Amazon’s voice aide Alexa, embedded in the company’s Echo speakers and Fire TV players, as well as some cars and house gadgets. Millions of Amazon customers ordered goods by voice with Alexa in the past year, said Olsavsky on a separate call with reporters.

“Our 2017 projections for Alexa were very optimistic, and we far exceeded them,” added Jeff Bezos, Amazon’s founder and chief executive, in a statement. “We don’t see positive surprises of this magnitude very often — expect us to double down.”

HEAVY SPENDING

Amazon’s stock has outperformed the S&P 500, rising almost 50 percent since the start of the fourth quarter to Thursday’s close, compared with the S&P’s 12 percent rise.

Its shares trade at a premium to those of many peers. The stock’s price-to-earnings ratio is nearly 12 times that of cloud computing rival Microsoft Corp, for instance.

Amazon Web Services (AWS), which is dueling with Microsoft to handle data and computing for large enterprises, saw its profit margin expand from the third quarter.

This was a “sign of platform strength despite increasing competition,” said Baird Equity Research analyst Colin Sebastian in a research note.

AWS posted a 45 percent rise in sales to $5.1 billion.

Amazon said it expects operating profit in the current quarter of between $300 million and $1 billion. Analysts were expecting $1.5 billion, according to analytics firm FactSet.

The company has become notorious for running on a low profit margin. Yet its big bets on new services and entry into new industries have reaped shareholders rewards over the past decade, including its founder Bezos, now the richest man in the world.

Amazon continues to spend on a wide array of areas. It is expanding its retail footprint outside the United States, particularly in India, and almost doubled its international operating loss to $919 million in the fourth quarter. Amazon’s global headcount is up 66 percent from a year ago at 566,000 full-time and part-time employees, thanks to a hiring spree and an influx of workers from Whole Foods Market.

And earlier this week, it announced a partnership with JPMorgan Chase & Co and Berkshire Hathaway Inc to determine how to cut health costs for hundreds of thousands of their employees.

The company said it plans to spend more on video content this year as well, with a prequel television series to “The Lord of the Rings” in the works. Analysts estimate Amazon spent $4.5 billion or more in 2017.

“Revenue and margins vastly exceeded expectations, and cost control was impressive, so that’s what people are focused on,” said Wedbush Securities analyst Michael Pachter, adding, “It’s clear that they will spend a lot more in 2018.”