SAN FRANCISCO — Facebook and Amazon are headed in different directions.

While Facebook weathered its worst day ever on Wall Street Thursday, Amazon reported another stellar quarter and continued on the path toward becoming the first company worth $1 trillion.

But it wasn’t always like this. Facebook has until recently been a model of financial consistency, relying on a formula of users, engagement and advertising revenue to post consistent growth and profits. Amazon, on the other hand, has had plenty of quarters where it did not report a profit, leaving open the question of whether CEO Jeff Bezos would ever reward Amazon investors.

Now, Amazon is leading the tech industry.

“In terms of the tech company today that has the most things going for them, in terms of fuel in the engine, it’s Amazon,” said Daniel Ives, chief strategy officer and head of technology research at GBH Insights.

On Thursday, Facebook stock shed almost 20 percent of its value after the company reported a decline in revenue and user growth. Engagement is also down on Facebook, something CEO Mark Zuckerberg warned would happen at the start of 2018 when he announced that Facebook would focus on creating more meaningful interactions.

Amazon, on the other hand, announced on Thursday that it generated twice as much profit in its second quarter than Wall Street analysts expected. Its shares rose 2 percent in after-hours trading.

While Facebook deals with misinformation, platform abuse and data privacy scandals, Amazon continues to power ahead. It claims more than 100 million Amazon Prime members. Its Amazon Web Services cloud computing business is highly profitable. And it is moving into a variety of other industries through acquisitions, including Whole Foods and most recently PillPack, an online pharmacy.

“Look in any recycling area and half the boxes are Amazon,” said Caleb Silver, editor in chief of Investopedia. “Its ubiquity is undeniable and it keeps moving into businesses where just a whiff of it entering those businesses can wipe billions off competitors’ market caps.”

Ives said Amazon’s track record of entering new industries and expanding its international business gives it room for growth.

Amazon has “massive tailwinds at their back,” Ives said. And the company's ability to build a “competitive moat” in various markets has been a “game changer.”

“They have expanded internationally and they have done it in such a way that now it is benefiting the bottom line,” he said.

But it hasn’t been completely smooth sailing for Amazon.

The company has proven to be President Donald Trump’s favorite punching bag on Twitter, where he has repeatedly and incorrectly lambasted Bezos for everything from costing the United States Post Office money to using the Washington Post, which Bezos owns, as a lobbying arm for Amazon.

The Amazon Washington Post has gone crazy against me ever since they lost the Internet Tax Case in the U.S. Supreme Court two months ago. Next up is the U.S. Post Office which they use, at a fraction of real cost, as their “delivery boy” for a BIG percentage of their packages.... — Donald J. Trump (@realDonaldTrump) July 23, 2018

In the battle between the Beltway and Bezos, Ives said the chatter is “more noise, rather than affecting the fundamentals and stock.”

Apple, currently the world’s most valuable company, could be in position to cross the $1 trillion threshold first due to its upcoming iPhone launch cycle. However, if Amazon keeps up its momentum, the company could beat Apple to the finish line, said Patrick Moorhead, principal analyst at Moor Insights & Strategy.

The majority of Apple’s business is in the relatively stable market of selling smartphones, Moorhead said, while Amazon has “more growth opportunities that are clearer.”

Moorhead pointed to Amazon Web Services, which serves businesses with cloud-based computing power and tools, and international retail as having room for growth.

“We’re talking about a market opportunity that is one trillion dollars,” Moorhead said. “From a retail perspective, Amazon is popular in some countries, including the United States and the United Kingdom, but it has so much growth potential.”

But that potential can come with the “double-edged sword” burden of meeting Wall Street’s higher expectations, Ives said. As the world learned from Facebook losing 20 percent of its value in less than one day, nothing golden necessarily lasts forever.

“Investors will continue to expect the company to perform like it has,” Ives said of Amazon. “Those are the inherent risks in every quarter.”