After months of speculation, intrigue, lawsuits, and presidential leaning-in, Microsoft has won the Pentagon’s $10 billion JEDI cloud storage contract, upsetting the presumed frontrunner Amazon Web Services.

The outcome comes as a surprise to many observers who described Amazon as the almost-certain winner of the Joint Enterprise Defense Infrastructure, or JEDI, program. Amazon was considered by many to be the only qualified bidder because it had the largest enterprise cloud infrastructure and already had reached the necessary highest security level, known as Impact Level 6.

Controversy has dogged the program from the beginning. Several competitors, led by Oracle, protested the Pentagon’s original requirements for the program, arguing that the rules favored Amazon over other, smaller providers. They even took their concerns directly to President Donald Trump, who has a well-known dislike for Amazon CEO Jeff Bezos. At one point, the president told then-Defense Secretary James Mattis to “screw” Amazon, according to a new book by a member of Mattis’s staff. In July, the president began to publicly question the competition; shortly thereafter, new Defense Secretary Mark Esper halted the program and launched a review. Just days ago, Esper unexpectedly announced he was recusing himself from the award decision because his son worked for IBM, a bidder that was eliminated in an early stage of the competition.

In a statement, Amazon officials expressed surprise at the announcement. AWS is currently the only cloud provider for the U.S. intelligence community, having hosted secret and top-secret classified data for nearly six years.

“We’re surprised about this conclusion. 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,” said an AWS spokesperson.

Microsoft’s advantage may have come from a deeper relationship with the Pentagon. Their business with the department has been picking up. In November, the U.S. Army chose the Microsoft HoloLens for its next-generation heads down data display for distributed infantry. Microsoft is also considered the certain winner in the Defense Department’s other cloud contract. And its Office 365 Suite is the centerpiece for both bidding companies in the Pentagon’s multibillion Defense Enterprise Office Solutions contract, which aims to provide a single suite of business cloud solutions to all defense agencies.

"We brought our best efforts to the rigorous JEDI evaluation process and appreciate that DoD has chosen Microsoft," Toni Townes-Whitley, president of Microsoft's U.S. Regulated Industries, said in a statement. "We are proud that we are an integral partner in DoD’s overall mission cloud strategy. As was articulated throughout the JEDI procurement, the DoD has a singular objective—to deploy the most innovative and secure commercially available technology to satisfy the urgent and critical needs of today’s warfighters. We look forward to expanding our longstanding partnership with DoD and support our men and women in uniform at home, abroad, and at the tactical edge with our latest unique and differentiated Azure cloud capabilities.”

The JEDI program is intended to give the Defense Department the same sort of enterprise cloud capabilities that many large commercial entities, such as Netflix, currently enjoy. Officials have argued that JEDI would be a vast improvement over the military’s current capability, a series of clouds and networks kludged together, a situation that contributes to massive data latency that is hindering operations. As conceived, JEDI is meant to unite the entire U.S. military — virtually every fighter on the ground, every ship at sea, and every jet in the air — within a single data framework. Defense Department officials have repeatedly said that a single enterprise cloud was essential for the sort of highly-networked, data-intensive fighting that the military would be called on to do in the event of a major conflict with a technologically sophisticated peer nation, such as China.

“Imagine the speed of operations in a fight in the Pacific,” Lt. Gen. Jack Shanahan, who runs the Pentagon’s Joint Artificial Intelligence Center, told reporters in August, “where you just do not have time to figure out how do I get my data, clean my data, move it from point A to point B. If I’m a warfighter, I want as much data as you could possibly give me. Let my algorithms sort through it at machine speed…It’s really hard for me to do that without an enterprise cloud solution.”

Defense officials have repeatedly said that while JEDI is the largest ever Pentagon cloud award, there will be other, smaller cloud awards in the future. But JEDI very much represents an important path forward. With the ability to share significantly more data, and faster, the department hopes to bring next-generation artificial intelligence capabilities online in the years ahead and share them across the battlefield. That can’t happen, they argue, if the data that those machine-learning algorithms need to produce insights and outputs is locked away in servers or networks that aren’t connected to the front lines.

“Right now, there are questions over whether cloud A is not interoperable with cloud B. What does it take to make that happen? How do I get data from over here to over here? I think we are seeing real, tangible examples of that playing out in Afghanistan right now, and that’s in a fight that we’re largely calling counterterrorism and counterinsurgency,” Shanahan said.

This article has been updated to include additional information.