With its stunning win of a lucrative $10 billion Pentagon technology contract Friday, Microsoft Corp. not only beat Amazon.com Inc. but also uprooted its larger rival as the federal government’s go-to cloud-computing vendor.

Microsoft’s MSFT, +2.27% cloud-computing powerhouse Azure, which scored another multibillion-dollar government contract in August, was awarded the Joint Enterprise Defense Infrastructure, or JEDI, contract Friday afternoon, edging out presumptive favorite Amazon Web Services. Oracle Corp. ORCL, +0.84% and International Business Machines Corp. IBM, +0.72% were eliminated earlier in the contentious monthslong bidding process, prompting Oracle to file a lawsuit disputing the selection process.

The Pentagon issued a short statement of Microsoft’s win late Friday on its website.

Amazon AMZN, +2.49% was long considered the slam-dunk favorite to land the 10-year deal, due in part to its $600 million cloud contract with the CIA and its expertise in streamlined data transfer, automated compliance systems and data-sharing platforms. More than 5,000 government agencies use AWS.

“We’re surprised about this conclusion,” an AWS spokesman told MarketWatch. “AWS is the clear leader in cloud computing, and a detailed assessment purely on the comparative offerings clearly lead to a different conclusion. We remain deeply committed to continuing to innovate for the new digital battlefield where security, efficiency, resiliency, and scalability of resources can be the difference between success and failure.”

The JEDI award sent Microsoft shares up 3% in after-hours trading Friday; Amazon’s stock was down 0.8%.

“We brought our best efforts to the rigorous JEDI evaluation process and appreciate that DoD has chosen Microsoft,” Toni Townes-Whitley, President, US Regulated Industries at Microsoft said in a statement. “We are proud that we are an integral partner in DoD’s overall mission cloud strategy.”

Wedbush Securities analyst Daniel Ives called Microsoft’s win a “game changer” that will “have a ripple effect” for the company’s cloud business for years.

“While AWS/Amazon have been in pole position to win this deal over the last year, our Beltway contacts had talked about Microsoft making ‘steady and impressive progress’ and significantly narrowed the gap over the last six months with the odds of a win looking more like a realistic possibility for Redmond vs. a pipe dream a year ago,” Ives said in a note late Friday.

The relationship between Amazon and the Pentagon was heavily scrutinized, and the procurement process was frozen since Aug. 1 while Defense Secretary Mark Esper examined the process. Esper recused himself on Tuesday from the contract’s award earlier this week. Stoking the animosity, President Trump publicly excoriated Amazon Chief Executive Jeff Bezos — who also owns The Washington Post — and ordered a review of the contract in July.

In his forthcoming book, former Secretary of Defense James Mattis claims Trump told him to “screw Amazon” out of the contract, according to a report on CNBC.

The surprise Microsoft win comes two months after the Defense Department and General Services Administration awarded the 10-year, $7.6 billion Defense Enterprise Office Solution (DEOS) contract to Microsoft vendors following a monthslong evaluation process by the GSA. DEOS would provide email, calendar, video-calling and other productivity tools to the U.S. military.

Read more:Microsoft vendors win $7.6 billion government deal

Despite the setback, AWS remains the dominant player in the cloud market.

The global public cloud services market is projected to grow to $221.6 billion in 2019 and reach $344.9 billion by 2022, according to market researcher Gartner. AWS is the clear winner in the market’s fastest-growing segment, infrastructure as a service, or IaaS. The segment is expected to reach $74.1 billion by 2022, and AWS currently is its largest vendor, with 48% of the market.

During 2017, Amazon was No. 1, with 49% of the IaaS market. Among the company’s big-name clients: Netflix Inc. NFLX, +2.07% , General Electric Co. GE, +0.99% , Comcast Corp. CMCSA, +0.98% , Apple Inc. AAPL, +3.75% , Lyft Inc. LYFT, +2.83% , Verizon Communications Inc. VZ, +0.33% , and McDonald’s Corp. MCD, +0.95% .

On Thursday, the company announced that AWS revenue climbed 35% to $9 billion year-over-year in the third quarter, though that was its slowest growth rate in more than five years. Microsoft’s Azure grew 59% in the quarter, the company revealed a day earlier, though it does not disclose gross revenue for the Azure unit. Alphabet Inc.’s GOOGL, +1.13% GOOG, +1.16% Google Cloud ison an $8 billion annual run-rate, according to an irregular disclosure last quarter by executives.

Earlier this month, Oracle vowed to add about 2,000 jobs to its cloud operations to compete with Amazon and Microsoft. Oracle declined to tell MarketWatch where most of the hires will take place.