Amazon.com Inc. followed Apple Inc. to become the second U.S. company to reach $1 trillion in market value, reflecting the online retailer’s striking transformation from a profitless bookseller into a disruptive force of commerce.

Shares of Amazon climbed 1.9% in midday trading Tuesday, briefly topping the $2,050.27 needed to push the company’s value above $1 trillion. The stock, which ended the day up 1.3%, has surged nearly 75% in 2018 and added roughly $430 billion to the company’s market capitalization—about the size of...