Apple (AAPL 0.64%) and Samsung (NASDAQOTH: SSNLF), the two largest smartphone makers in the world, are bitter rivals in the mobile market. But behind the scenes, Apple is actually Samsung's biggest external customer for components.

Samsung recently assigned a dedicated team of around 200 employees to develop screens for Apple's iPads and MacBooks, according to Bloomberg. Samsung will also manufacture the majority of Apple's upcoming A9 chips for its next-generation devices.

Source: Apple.

These developments indicate that the relationship between the two companies, which has been locked in patent litigation over the past four years, is improving. Last year, both companies agreed to drop all patent litigation outside the United States.

Why does Apple need Samsung?
Apple and Samsung weren't always competitors. Samsung supplied the processor, application memory, flash storage, and displays for many of Apple's devices. By 2010, Apple was one of Samsung's biggest customers, spending $6 billion per year on its components.

But that same year, Samsung launched its first Galaxy S handset, which closely resembled Apple's iPhone 3GS from the prior year. In 2011, Apple sued Samsung for copying its iPhone designs. Samsung countersued, claiming that Apple was using its wireless-transmission technology without permission.

To reduce its dependence on Samsung, Apple held talks with TSMC (TSM 2.84%), Samsung's main chip fabrication rival, to build new chips. Apple wanted to either buy a stake of TSMC, or have the foundry set aside factory space for the exclusive production of Apple chips. TSMC rejected Apple's plan, stating that the deal would undermine its independence and flexibility.

A lack of suitable partners
Nonetheless, Apple continued buying components from Samsung, paying roughly $10 billion to its rival in 2012, according to Sanford Bernstein analyst Mark Newman. That was equivalent to roughly 17% of Samsung's total component sales that year. That figure likely climbed to $13 billion in 2013, according to Morgan Stanley.

TSMC agreed to manufacture some of Apple's A8 chips for the iPhone 6 and 6 Plus, but Samsung still reportedly supplied 40% of the chips, according to research firm IHS.

Samsung owns one of four foundries that can manufacture 14nm chips. The other three belong to Intel (INTC -0.38%), TSMC, and GlobalFoundries. Therefore, Apple's choices are quite limited. The A9, which will be a 14nm design, will reportedly be manufactured by Samsung and GlobalFoundries, with Samsung supplying the majority of the chips.

Why does Samsung need Apple?
Samsung needs component sales to offset its market losses in mobile devices. Between the fourth quarters of 2013 and 2014, Samsung's global market share in smartphones fell from 28.9% to 19.9%, according to IDC. During that time, Apple's share rose from 17.5% to 19.7%.

Samsung's decline was caused by the rise of cheaper Chinese rivals like Xiaomi, and Apple nullifying Samsung's big screen advantage with the iPhone 6 and 6 Plus. As a result, revenue at Samsung's mobile division, which accounted for 52% of its top line, fell 21% annually in 2014. The division's operating profit, which comprised of its bottom line, plunged 42%.

Samsung's device solutions (DS) business, which sells components to other OEMs, generated 32% of its revenue and 38% of its operating profit in 2014. Last year, the former fell 3% year over year as the latter slipped 6%. Therefore, selling more components to Apple could strengthen Samsung's DS business and help the company profit from Apple's success.

Source: Apple.

The verdict
A closer relationship between Apple and Samsung benefits both companies. Both companies stop wasting millions on litigation. Apple gets more displays, processors, and other components from a single manufacturer, which decreases hardware fragmentation. Samsung's DS business gets a boost, which can help it offset losses at its mobile division. However, this deal is bad news for other suppliers like TSMC and LG, which previously benefited from the growing rift between Apple and Samsung.