Heineken, the world's second-largest brewer, has agreed to buy the loss-making Brazilian breweries of Japan's Kirin Holdings, boosting its presence in the world's third biggest beer market. 

The Dutch brewer will become the second largest beermaker in Brazil, with a share of about 19%, behind market leader Anheuser Busch InBev. 

Including debt, Heineken said it would pay €1.025 billion for Brasil Kirin. 

For Kirin it marks a departure from the Brazilian market, having paid some $3.9 billion in 2011 for 12 breweries, a business which has subsequently lost market share and seen raw materials costs rise due to a weak currency and rampant cost inflation. 

Kirin said that Brazil's economic risks and a stagnant and competitive beer and soft drink market meant there were "limitations" to making Brasil Kirin profitable.

Kirin said the unit made an operating loss of 284 million reais in 2016. 

Brazil's economy is set to enter a third year of recession in 2017, but Heineken said that the nation's beer market was attractive in the longer term, with a premium segment growing faster than the market as a whole. 

The acquisition will increase Heineken's presence in the north and northeast of Brazil, allow it to boost sales of the premium lagers Heineken and Sol and yield cost savings. 

It already has five breweries in Brazil from its 2010 acquisition of the beer business of Mexico's FEMSA. 

Some analysts have said the deal is important as it makes Heineken a stronger rival in a heartland of global beer leader AB InBev just as the latter has pushed into Heineken's markets elsewhere through its takeover of SABMiller.

The acquisition, dependent on approval by Brazil's competition agency, is expected to close in the first half of the year. 

Separately, Kirin said it would take a 51% stake in a beer company in Myanmar. 

The company, Mandalay Brewery Ltd, will be 49% owned by Myanmar Economic Holdings. Kirin and Myanmar Economic Holdings already run already another beer joint venture, Myanmar Brewery. 

Kirin also said it had ended capital alliance talks with Coca-Cola Group, though the two companies would continue to discuss a potential operational partnership.