After losing $2.8 billion since it was founded in 1995, the online retailer Amazon.com said yesterday that it had made its first quarterly profit, $5 million, validating at least in part its strategy to grow rapidly first and worry about profits later.

Amazon's financial results were far better than expected because a yearlong efficiency drive sharply cut costs even as sales grew. An accounting gain related to the decline of the euro's value provided a final push. So the company was able to show a profit by the conventional standard, rather than merely by the nonstandard ''pro forma'' measures that it and other Internet companies prefer.

''They have brought the company back from the brink and made it viable,'' said Mark Rowen, a Prudential Securities analyst who has long been a critic of Amazon. ''Where the company was a year ago and where it is today is like night and day.''

Jeff Bezos, the company's founder and chief executive, said the biggest surprise had been how quickly customers reacted to the company's decision last summer to offer 30 percent discounts on books costing more than $20.