Salesforce said Thursday it will move its Marketing Cloud service to Microsoft's Azure public cloud, putting aside the rivalry between the two companies.

Microsoft's share of the public cloud market remains smaller than market leader Amazon Web Services but has gained wider adoption from customers under CEO Satya Nadella. Last month, Microsoft won a contract to provide the Pentagon with cloud-computing services in a deal that could be worth as much as $10 billion, and in July, Microsoft announced a cloud agreement with AT&T.

Salesforce and Microsoft have had a complicated relationship over the years, with executives taking occasional public potshots at each other. They compete in multiple areas, including Salesforce's core business of customer relationship management: Salesforce has the Sales Cloud and Microsoft fields the less popular Dynamics 365 cloud service.

In a 2014 detente, the companies signed a product partnership. Salesforce founder and CEO Marc Benioff credited Nadella's collaborative approach as driving the turnaround and even invited him to a prime speaking position at the company's Dreamforce conference. In 2015, Microsoft considered buying Salesforce, but talks broke down over price.

Then in 2016, the companies got into a fierce bidding war over LinkedIn, which Microsoft ended up winning, and Benioff's rhetoric soured. "You know, maybe the new Microsoft is actually the old Microsoft," he told CNBC's Jim Cramer.

Now, Salesforce has chosen Microsoft's cloud infrastructure to run one of its products around the world. Under Nadella, Microsoft has also previously allied with competitors like Red Hat and VMware.

In addition to adopting Azure, Salesforce will also develop technology to integrate its Sales Cloud and Service cloud products with Microsoft's Teams communication app. Teams competes with Slack, and Salesforce has its own social network for internal business discussion called Chatter. The idea is to enhance interoperability between Chatter and Teams, according to a person familiar with the matter.

Salesforce currently depends on Amazon's cloud to help run its online services, and in 2017 it said it would also use Alphabet's Google Cloud Platform to deliver services. Salesforce to date has run Marketing Cloud on its own internal infrastructure, a spokesperson told CNBC.

Representatives of the two companies declined to talk about how much Salesforce will spend on Azure.

WATCH: Microsoft announces $1 billion investment in Elon Musk-backed AI company