The giant contract has attracted more attention than most, sparked by speculation early in the process that Amazon would be the sole winner of the deal.
The Pentagon awarded Microsoft a $10 billion cloud computing contract, snubbing early front-runner Amazon, whose competitive bid drew criticism from President Donald Trump and its business rivals.
Bidding for the huge project, known as Joint Enterprise Defense Infrastructure, or JEDI, pitted leading tech titans Microsoft, Amazon, Oracle and IBM against one another.
The giant contract has attracted more attention than most, sparked by speculation early in the process that Amazon would be the sole winner of the deal. Tech giants Oracle and IBM pushed back with their own bids and also formally protested the bidding process last year.
Oracle later challenged the process in federal court but lost.
Trump waded into the fray in July, saying that the administration would "take a very long look" at the process, saying he had heard complaints. Trump has frequently expressed his ire for Amazon and founder Jeff Bezos, who also owns the Washington Post. At the time, he said other companies told him that the contract "wasn't competitively bid."
Defense Secretary Mark Esper recused himself from the controversial bidding process earlier this week, citing a conflict of interest because his son works for one of the companies that originally bid.
The JEDI system will store and process vast amounts of classified data, allowing the US military to use artificial intelligence to speed up its war planning and fighting capabilities.
A cloud strategy document unveiled by the Defense Department last year called for replacing the military's "disjointed and stove-piped information systems" with a commercial cloud service "that will empower the warfighter with data and is critical to maintaining our military's technological advantage."
The Pentagon emphasised in an announcement that the process was fair and followed procurement guidelines. It noted that over the past two years, it has awarded more than $11 billion in ten separate cloud-computing contracts, and said the JEDI award "continues our strategy of a multi-vendor, multi-cloud environment."
The latter statement appeared designed to address previous criticism about awarding such a large deal to one company.
The deal is a major win for Microsoft's cloud business Azure, which has long been playing catch-up to Amazon's market-leading Amazon Web Services.
Microsoft said it was preparing a statement.
Amazon said Friday it was surprised by the decision.
"AWS is the clear leader in cloud computing, and a detailed assessment purely on the comparative offerings clearly lead to a different conclusion," Amazon spokesman Drew Herdener said in a statement. "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."
According to a July report from the research firm Gartn er, Amazon holds almost 48% of the market for public cloud computing, followed by Microsoft in second place with close to 16%.
Over the last year, Microsoft has positioned itself as a friend to the U.S. military. President Brad Smith wrote last fall that Microsoft has long supplied technology to the military and would continue to do so, despite pushback from employees.
Oracle and IBM were eliminated earlier in the process, leaving Microsoft and Amazon to battle it out at the end.
Google decided last year not to compete for the contract, saying it would conflict with its AI ethics principles.
Google employees have been especially vocal in protesting the company's involvement with government contracts.
"It's a paradigm changer for Microsoft to win JEDI," said Dan Ives, managing director of Wedbush Securities. "And it's a huge black eye for Amazon and Bezos."
Microsoft, Amazon, Google and other tech giants have faced criticism from their own employees about doing business with the government, especially on military and immigration-related projects.