NEW YORK (AP) — Microsoft and Samsung Electronics have agreed to cross-license each other's patent portfolios, with Microsoft getting royalties for the mobile phones and tablets Samsung sells that run the Android operating system.

Microsoft Corp. and Samsung Electronics Co. said Wednesday that they also will work together to develop and market Microsoft's Windows Phone software. The deal, which is likely to help Microsoft gain more exposure for the Windows Phone, comes a year and a half after the company signed a similar deal with HTC, which was also reached without filing lawsuits.

Financial terms were not disclosed, though Evercore Partners analyst Kirk Materne said the amount Microsoft will likely get per phone is "fairly low." More importantly, he said the Redmond, Wash., company is working to boost its relationships with phone manufacturers so that it is at an advantage when it comes out with its own operating system.

Microsoft is scrambling to build a mobile version of Windows that will be more widely embraced in the smartphone market, where it has fallen behind Google's Android as well as Apple's iPhone operating system.

For Samsung, the deal likely means that the company recognizes that once Google bought Motorola Mobility Holdings Inc., "where Android was going to go longer-term was changing," Materne said. In other words, diversifying what operating system its phones run could only be a positive now that the company behind Android owns one of its competitors.

"The deal helps cover their bases," Materne said.

Research firm IDC says Samsung was the No. 2 smartphone maker in the world in the second quarter, behind Apple Inc. Samsung's Galaxy phones, which propelled it to No. 2 from No. 4 in the smartphone market, run on Android.