For more than a decade, Apple was the stock market’s undisputed king. It first overtook Exxon Mobil as the world’s most valuable public company in 2011 and held the title almost without interruption.

But a transfer of power has begun.

On Friday, Microsoft surpassed Apple, claiming the crown after its market value surged by more than $1 trillion over the past year. Microsoft finished the day at $2.89 trillion, higher than Apple’s $2.87 trillion, according to Bloomberg.

The change is part of a reordering of the stock market that was set in motion by the advent of generative artificial intelligence. The technology, which can answer questions, create images and write code, has been heralded for its potential to disrupt businesses and create trillions of dollars in economic value.

When Apple replaced Exxon, it ushered in an era of tech supremacy. The values of Apple, Amazon, Facebook, Microsoft and Google dwarfed former market leaders like Walmart, JPMorgan Chase and General Motors.

The tech industry still dominates the top of the list, but the companies with the most momentum have put generative A.I. at the forefront of their future business plans. The combined value of Microsoft, Nvidia and Alphabet, Google’s parent company, increased by $2.5 trillion last year. Their performances outshined Apple, which posted a smaller share price increase in 2023.

“It simply comes down to gen A.I.,” said Brad Reback, an analyst at the investment bank Stifel. Generative A.I. will have an impact on all of Microsoft’s businesses, including its largest, he said, while “Apple doesn’t have much of an A.I. story yet.”

Microsoft and Apple declined to comment.

Microsoft has not led a technology transition since the personal computing era, when its Windows operating system dominated sales. It was late to the internet, mobile phone and social media.

When Satya Nadella became Microsoft’s chief executive in 2014, the company was floundering. He refocused it on the growing cloud computing business, turning it into a strong challenger to Amazon, the pioneer in the field. Then Mr. Nadella pushed the company forward again, making an aggressive bet on generative A.I.

In 2019, Mr. Nadella made Microsoft’s first of several investments in OpenAI, the start-up that would build the A.I.-powered ChatGPT chatbot. In the end of the summer of 2022, he was impressed by a preview of OpenAI’s underlying technology, known as GPT-4, and soon began prodding Microsoft to add generative A.I. to its products at what he called a “frantic pace.”

He started with adding a chatbot to the Bing search engine, but then began pushing A.I. into the Windows operating system and productive applications like Excel and Outlook, and offering OpenAI’s systems to customers of Azure, Microsoft’s flagship cloud computing product.

The revenue has only just started to show up in Microsoft’s financial results. Generative A.I. accounted for about three percentage points of growth to Azure in the three months that ended in September, and the $30-a-month offering inside Microsoft’s productivity software began a general release only in November.

(The New York Times has sued OpenAI and Microsoft, accusing them of copyright infringement.)

This isn’t the first time that Microsoft has pulled ahead of Apple in recent years. It did so in 2018, as its cloud-computing business began to flourish, and in 2021, when the pandemic disrupted Apple’s iPhone operations. But this change could be more indicative of a fundamental shift in the tech industry.

“The question is: Who has the better mouse trap to go to the next level of $3.5 trillion?” said Dan Morgan, portfolio manager and analyst at Synovus Trust, a bank in the Southeast. “You can make the case that Microsoft is in the better position. Apple has been struggling for the next big thing.”

The iPhone, which debuted in 2007, catapulted Apple to the top of the stock market. Between 2009 and 2015, the company went from selling 20 million iPhones a year to more than 200 million.

When device sales slowed in recent years, Tim Cook, Apple’s chief executive, shifted the company’s focus from selling more iPhones to selling people more apps and services on their existing iPhones. The strategy helped Apple’s annual revenue soar to $383 billion, a nearly fourfold increase from the end of 2011, the year that Steve Jobs, Apple’s co-founder, died.

Mr. Cook’s strategy has shown signs of fatigue. The iPhone, which accounts for more than half of Apple’s revenue, has become known more for its incremental improvements each year than its noteworthy innovations. Purchases of iPads and Macs have declined. And the sales growth of its services such as Apple Music are slowing.

Last year, the company’s sales fell for four consecutive quarters. But shares of Apple still rose around 50 percent last year, and investors lifted its market value to nearly $3 trillion because of their belief that demand for the iPhone would continue.

Wall Street analysts have predicted that this year’s iPhone sales will be weak. The company is facing challenges in China, where Huawei has released a new phone and the government is restricting the use of foreign smartphones.

While Microsoft and others have been building new generative A.I. businesses, Apple has been absent from the conversation. During a call with analysts last year, Mr. Cook said Apple had work “going on” connected to A.I., but he declined to elaborate.

Last year, Apple engineers were testing a large language model, which can power a chatbot, The Times reported. The company has also held discussions with publishers about acquiring material to train generative A.I. systems. But it has yet to release anything publicly.

“Apple needs to take note that if they want to maintain their spot as one of the most innovative tech companies, they have to get behind A.I. in a big way,” said Gene Munster, managing partner at Deepwater Asset Management.

Apple has been focused on the release of an augmented reality headset, the Vision Pro. The device, which will ship Feb. 2, is the first major new product category that the company has released since the Apple Watch in 2014. Analysts project Apple will sell fewer than half a million units.