Reuters/Shannon Stapleton

Microsoft briefly surpassed Apple as the most valuable US company.

It passed Apple on Monday with a market value of about $812 billion.

Watch Microsoft and Apple trade live.

Microsoft on Monday briefly surpassed Apple as the most valuable company in the US, with a market capitalization of about $812 billion. Still, Apple was back on top by the stock market's close, with a market value of more than $825 billion. The last time Microsoft was more valuable than Apple was in 2010.

It was a somewhat surprising turn of events, as less than two months ago Microsoft's market value topped out at $887 billion while Apple's reached a peak above $1.12 trillion. In August, Apple became the first US company with a $1 trillion valuation.

But a lot has happened since then, as the stock market suffered through its so-called Red October, one of its worst months since the financial crisis, with the tech-heavy Nasdaq Composite shedding more than 12%.

Read more: Microsoft's CTO lays out the 2 tech trends he believes will change the world: 'People haven't wrapped their heads around this yet'

Apple has gotten mauled since early October, as the tech sell-off and fears of slowing demand for its iPhones weighed. Shares have tumbled into a bear market, down nearly 24% from their September peak. Several suppliers have cut their forecasts, citing a drop in smartphone demand. That caused Goldman Sachs to lower its price target for a third time in November to $182 — about 6% above where shares were trading Monday.

Microsoft has managed to hold up better than other high-flying tech names after its first-quarter results showed it continuing to follow through on the vision of CEO Satya Nadella. When he took over in 2014, Nadella said he wanted to focus on its subscription-based businesses and the cloud.

And while sales of its cloud-computing unit, Azure, grew at their slowest pace in at least two years, they were still up 76% annually, remaining the strongest rival to the dominant Amazon Web Services. Microsoft shares are down 8% from their September close at about $105 each.

Markets Insider

NOW WATCH: The first woman in space almost didn't make it back to Earth and she had to keep it a secret for 30 years