Amazon.com posted its first quarterly loss since 2003 and warned of another possible loss for the three-month period under way, sending its stock down late Thursday.

While worse than expected, the loss was not entirely a surprise.

For more than a year, the company has been spending heavily on new distribution centers, Kindle devices and digital-media content, and that clearly continued in the third quarter.

“Amazon is positioning itself for the digitization of media. It has no choice,” said BGC Partners analyst Collin Gillis. “How long are people going to be buying physical DVDs, CDs and books printed on dead trees? Probably not much longer.”

The world’s largest Internet retailer reported a third-quarter loss of $274 million, or 60 cents a share, vs. a profit of $63 million, or 14 cents, a year ago.

Amazon said weakness at daily-deals website LivingSocial, which it partly owns, dragged down results.

Before Thursday, Amazon’s profit had declined on a year-over-year basis in each of the previous six quarters.

But Wall Street has focused instead on the company’s rapid sales growth during that period, pushing its stock up 29 percent so far this year. Whether that continues now that Amazon has swung to a loss remains to be seen.

Shares closed Thursday down $5.57 to $222.92, then fell an additional $2.22 to $220.70 in late-trading after the earnings report.

Gillis, who rates the stock a “hold,” said the stock is too expensive given the results.

“Normally, when companies pivot, there’s a discount in the stock, and that has not happened with Amazon,” he said.

But Caris & Co. analyst Scott Tilghman said Amazon’s results are better than they appear, especially after adjusting for unfavorable currency fluctuations. A closer look at the growth in Amazon’s spending suggests its current investment cycle is drawing to a close, he said.

“We had expenses growing at a much faster rate than revenue from mid-2010 through 2011. And while expenses are still growing, the gap is narrowing considerably,” he said. “We now look on track for operating margins to begin to improve year-over-year in the first quarter of 2013.”

Looking ahead, Amazon projected fourth-quarter sales growth of between 16 and 31 percent. It predicted an operating loss of as much as $490 million or a gain of up to $310 million.

Amazon last month unveiled a new lineup of Kindle e-readers and tablet computers to take on a crowded field that now includes the iPad Mini, Microsoft Surface and Google’s Nexus 7.

Amazon aims to sell Kindle devices at near-break-even to stimulate demand for other items sold on its website. In a statement, CEO Jeff Bezos said ”our approach is working,” but as usual no financial breakout was given.

Amazon also recently began collecting sales taxes in California, Pennsylvania and Texas, bringing to eight the number of states where it must do so.

Analysts say Amazon’s sales could suffer as it loses a longtime price advantage over traditional stores.

But in a call with analysts Thursday, Chief Financial Officer Tom Szkutak said it’s too early to assess the effects of those new tax rules on its business.

Additionally, Amazon disclosed in early October that it agreed to buy its 11-building South Lake Union headquarters complex from developer Vulcan Real Estate for $1.16 billion.

Amazon said at the time it already had made a nonrefundable deposit of $23 million and would put down $28 million more this past Monday.