* Indonesia to gain 51.38 pct stake in Freeport's local unit
* Freeport now closer to ending years of acrimony
* Rio Tinto to sell stake in Grasberg mine (Recasts throughout) Taylor
JAKARTA/TORONTO, July 12 (Reuters) - Freeport-McMoRan Inc said on Thursday it will sell a majority stake in the world's second-biggest copper mine to the Indonesian government, seemingly ending a long-running dispute via a series of complex deals worth $3.85 billion.
The agreement, which could still collapse, will see Freeport give up majority control but remain the operator of the Grasberg mine, located in the country's eastern province of Papua, as Jakarta seeks to gain greater control over its mineral wealth.
Freeport accepted far less than it could have gotten for its majority Grasberg stake, highlighting the company's desire to end an acrimonious chapter that had weighed on its shares for more than six years. The company risked getting nothing had the case moved to arbitration.
Shares of Phoenix, Arizona-based Freeport were down slightly in Thursday afternoon trading.
"Freeport left money on the table to get this deal done," Freeport Chief Executive Officer Richard Adkerson said on a conference call with investors after a signing ceremony in Jakarta. "It's a new day for Freeport, and a new day for our working with the government."
It was not immediately clear if the agreement would be binding. While Freeport and Rio both said the agreement was non-binding, Jakarta said it was a binding deal.
The transactions will be completed this month, said State-Owned Enterprises Minister Rini Soemarno.
The deal could be a boon for Freeport's stock, which has fallen behind peers. Most analysts believe the stock should trade about 14 percent above current levels, according to Thomson Reuters data.
"Just to have clarity is critically important because for many investors, Freeport has been uninvestable because of the uncertainty around Grasberg," Jefferies mining analyst Christopher LaFemina said in an interview.
Under the agreement, Indonesian state-owned miner PT Inalum plans to acquire the Indonesian unit of Rio Tinto , which holds a 40 percent participating interest in Grasberg, for $3.5 billion.
That interest would then be transferred to Freeport's local unit, PT Freeport Indonesia, and converted into a 40 percent equity holding in the unit via a rights issuance that would then be given to Inalum.
A subsequent purchase of the share of Grasberg held by Freeport unit PT Indocopper Investama, valued at $350 million, would give Indonesia a total holding of 51.38 percent in Freeport Indonesia.
Estimates on the value of that stake vary. Jefferies values it at $800 million, while some estimates are lower.
Freeport, which will hold about 49 percent of Grasberg when the agreement is set, has also agreed to build a smelter in Indonesia within five years of the deal being signed, Adkerson said.
The two sides had agreed in principle last August to a deal. Thursday's agreement hammers out most of the specifics.
Rio for its part said it hoped for binding agreements by the end of the year, adding in a statement "there is no certainty that a transaction will be completed."
Indonesian President Joko Widodo praised the agreement as "a leap forward."
"We have to have a larger amount of income from tax, royalties, dividends ... so the value of our mining sector can benefit everybody," Widodo said at the ceremony.
Sealing a deal to get a majority stake for Indonesia in Grasberg is a priority for Widodo, who is widely expected to seek a second term in office in presidential elections next year.
The deal is also critical for the massive investment needed to develop underground mines at Grasberg as the current open-pit operation is phased out this year.
Still, planned agreements on how Freeport will manage mine operations with Inalum as the majority shareholder also need to be resolved.
Adkerson, Freeport's CEO since 2003, said that under the agreement Freeport alone will have authority to manage mine operations, but Inalum will work as an equal partner at the board level.
Inalum wants Freeport to "take the lead," he said, because Grasberg is "the most complicated mine in the world to operate." The high-altitude mine operates in an extremely rugged and remote area of New Guinea surrounded by jungle.
Efforts to finalise a deal have been complicated by concerns over the environmental impact of the project, in particular its handling of mine waste or tailings.
Environment Minister Siti Nurbaya must still issue a recommendation to Freeport Indonesia before the miner can secure the rights to Grasberg up to 2041. (Additional reporting by Gayatri Suroyo and Maikel Jefriando in JAKARTA Writing by Ernest Scheyder, Fergus Jensen and Ed Davies Editing by Christian Schmollinger, Frances Kerry and James Dalgleish)