(CNN) Microsoft has won a hotly contested contract to provide cloud computing services to the Defense Department, besting Amazon in a months-long competition in which President Donald Trump threatened to intervene.

The contract for the Joint Enterprise Defense Infrastructure is said to be worth billions of dollars over the coming decade.

Amazon had long been considered the favorite to win the contract. But that changed after Trump began raising questions about whether the process had been fair. Trump has long been critical of Amazon and its founder and CEO, Jeff Bezos.

Trump's interjection was soon followed by an examination of the contract launched by Defense Secretary Mark Esper. Esper attended numerous informational briefings about the contract, according to the Pentagon.

Earlier this week, Defense officials suddenly said Esper was recusing himself from the final decision-making process. Friday's award to Microsoft came days later.

Read More