TOKYO/MUMBAI (Reuters) - India's Sun Pharmaceutical Industries Ltd (>> Sun Pharmaceutical Industries Limited) has agreed to buy generic drugmaker Ranbaxy Laboratories Ltd (>> Ranbaxy Laboratories Limited) for $3.2 billion, betting it can fix factory quality glitches that plagued the current owner, Japan's Daiichi Sankyo Co (>> DAIICHI SANKYO COMPANY, LIMITED), and got Ranbaxy India-made drugs barred from the United States.

The all-share transaction, the biggest pharmaceutical sector deal in the Asia-Pacific region this year, will create the world's fifth-largest maker of generic drugs. The acquisition comes as the pace of consolidation increases in a market that's primed for growth in the U.S. and emerging markets and could be worth $335 billion globally by 2017, according to Lucintel.

For Daiichi Sankyo, Japan's fourth-biggest drugmaker by revenue, the deal marks a significant retreat and highlights the lingering quality problems facing India's drug industry. The value of the Japanese firm's investments in the country has been halved since it bought control of Ranbaxy in 2008.

The deal comes against the backdrop of a slew of sanctions against Ranbaxy by the U.S. Food and Drug Administration (FDA) due to concerns about manufacturing processes at its India plants. Sun Pharma's strong sales base in the U.S., along with India supply chain management that has been tight enough to meet FDA standards in most cases and a good record in managing troubled acquisitions, made the firm an attractive buyer for Daiichi Sankyo.

For Sun Pharma, the relatively rare purchase by a leading Indian company of a local rival creates the biggest generic drug business by sales in India, with combined revenue estimated at $4.2 billion. Under terms of the agreed deal, Ranbaxy shareholders will get 0.8 Sun Pharma shares for each Ranbaxy share they own.

"This transaction helps us transition to our long-held ambition of becoming a successful Indian company in the global pharmaceutical space," Dilip Shanghvi, managing director of Sun Pharma, India's largest drugmaker by market value, said in a conference call with analysts. Including Ranbaxy debt, the overall value of the transaction is $4 billion.

The global generic drugs sector has also seen a wave of mergers recently as companies seek economies of scale in an industry that sells low-cost, commodity products.

The sector has had a good run in the past decade selling copycat versions of medicines but recently times have got harder, thanks to a dwindling number of patent expirations. Mergers are seen as one way to improve efficiencies. Analysts estimate that recent deals in the sector have led to savings of about 8 percent of sales.

The deal relieves Daiichi Sankyo of a troubled subsidiary that has diverted resources and weighed on profits - at a price.

Under the deal, expected to close by year-end, the Japanese company will end up with a stake of about 9 percent in Sun Pharma valued at about $2 billion, compared with the $4.2 billion it paid for a 63.9 percent stake in Ranbaxy in 2008.

"Given Ranbaxy's problems, I'm sure Sun would have spent some time doing their homework on this issue," Sujay Shetty, pharmaceuticals leader for PricewaterhouseCoopers in India told Reuters. "To me, as a layman, it's not obvious that it is going to go away just now, but maybe Sun probably has assessed it to be something they can get on top of."

Daiichi Sankyo Chief Executive Joji Nakayama said Daiichi had learnt a lot about emerging markets through its relationship with Ranbaxy and saw those lessons as valuable for its further global expansion. The Ranbaxy deal was intended to establish a 'hybrid' business model offering generic medicines as well as innovative brands sold by the Japanese firm.

The company wrote down 359.5 billion yen ($3.5 billion) in 2009 to cover a drop in value of its initial investment after regulatory problems in the U.S. triggered a sharp fall in Ranbaxy's share price. The stock has since recovered, more than doubling since a March 2009 trough.

"We don't think we can make much progress in emerging markets with just innovative medicines," said Nakayama, speaking at a news conference in Tokyo. "So we are exploring many different possibilities for emerging markets, including tying up with local partners and we believe that will expand our business chances."

QUALITY CONCERNS

The broader issue of the quality of drugmaking has become a major concern both inside India and across the sector. India is second only to Canada as a drug exporter to the U.S., where it supplies about 40 percent of generic and over-the-counter drugs.

The FDA, which last month called for more collaboration with the Indian regulator to improve drug quality, has banned imports from all the Indian plants of Ranbaxy over production quality lapses.

Sun Pharma, whose plant at Karkhadi in the western state of Gujarat was banned from shipping products to the U.S. last month, has been the subject of comparatively fewer regulatory actions in the past.

The company's managing director Shanghvi said the combined entity would focus on the fixing manufacturing quality issues at Ranbaxy so that facilities currently banned from shipping to the U.S., the biggest export market for both Ranbaxy and Sun, can resume exports.

"The quality of business at Ranbaxy is in no way inferior to business at Sun Pharmaceutical," he said. "Our focus will be to address the issue of achieving compliance. We are not looking at synergies of manufacturing; the focus is to achieve compliance."

Sun Pharma, which will get access to Ranbaxy's new product pipeline including a generic version of AstraZeneca's (>> AstraZeneca plc) heartburn drug Nexium, said the acquisition is expected to be accretive to earnings per share in the first full year.

The deal values Ranbaxy shares at 457 rupees apiece, representing an 18 pct premium to their 30-day volume-weighted average share price.

Sun Pharma shares rose as much as 4 percent in Mumbai on Monday before ending the day up 2.9 percent. Ranbaxy, whose shares rose by nearly a quarter over the previous three sessions, fell 3 percent to 445.75 rupees.

Bank of America Merrill Lynch upgraded Sun Pharma to buy from neutral, saying that Ranbaxy's regulatory tangle was already at its height. There was "significant scope for operational improvement", it said, since Sun has a successful track record of turning around distressed assets.

Sun Pharma in 2010 bought all the outstanding shares of U.S.-based Caraco Pharmaceutical Laboratories at a time when Caraco was struggling to address manufacturing quality concerns that led to FDA bans on its plants. Sun was able to resolve those issues and Caraco plants resumed production in 2012.

Shares in Daiichi Sankyo climbed as much as 5 percent in Tokyo to a two-and-a-half-month high of 1,844 yen. Analysts welcomed the deal, saying it doesn't necessarily signal a pullback from India by Daiichi Sankyo.

"I wouldn't call this an exit. It's an ownership transfer," said Jefferies & Co analyst Naomi Kumagai. "Another company will take over control for them of a place that had a lot of issues. In that sense, it should be a good thing."

In a separate statement, Daiichi Sankyo said the U.S. Attorney's Office in New Jersey had issued an administrative subpoena to Ranbaxy seeking information related to the company's Toansa plant in India. Ranbaxy is cooperating with the information request.

Under the terms of the deal, Daiichi Sankyo has agreed to indemnify Sun Pharma and Ranbaxy for, among other things, certain costs and expenses that may arise from the subpoena, the company's statement said.

Citigroup (>> Citigroup Inc) and Evercore Partners are advising Sun Pharma, while Daiichi is being advised by Goldman Sachs Group (>> Goldman Sachs Group Inc) and ICICI Securities is the financial adviser to Ranbaxy, the statement said.

($1 = 103.5750 Japanese Yen)

(Additional reporting by Sophie Knight, Dominic Lau and Edmund Klamann in TOKYO, Denny Thomas in HONG KONG and Ben Hirschler in LONDON; Writing by Sumeet Chatterjee; Editing by Kenneth Maxwell)

By Chang-Ran Kim and Zeba Siddiqui