JAKARTA (Reuters) - Indonesia's government left no doubts as to who it believes got the better deal in its landmark agreement with Freeport McMoRan Inc (>> Freeport-McMoran) on the future of the Grasberg copper mine.

After Freeport agreed to divest a 51 percent stake in Grasberg, the world's second-biggest copper mine, Indonesia's Energy and Finance Ministries posted on social media #FreeportTaatIndonesiaBerdaulat, or "Freeport is obedient, Indonesia is a sovereign state".

The bombastic statement illustrates Indonesia's view that the dispute with Freeport over the mine was all about asserting the country's rights to its mineral resources. While Indonesia can point to a victory that appeals to nationalist sentiment, pinning down the details on the divestment indicates a further fight with Freeport.

Indonesia's President Joko Widodo was the driving force behind the agreement demanding the divestment, a new smelter at the mine and that Freeport pay higher taxes, Energy and Mineral Resources Minister Ignasius Jonan told reporters on Tuesday.

The Phoenix, Arizona-based company said it will divest 51 percent of PT Freeport Indonesia (PT-FI) and build a second smelter at Grasberg, in the eastern province of Papua, and will also commit to invest up to $20 billion in the mine.

In return, Freeport can "immediately" apply for a 10-year extension of its operations from 2021, and potentially maintain operational control through 2041, paying fixed, albeit higher, tax and royalty rates during that term.

"While there are a lot of issues still to be worked out, politically this is a win for the government," said Keith Loveard, a senior analyst at Jakarta-based Concord Consulting. "It has taken on a big U.S. firm and appears to have won."

The biggest of the raft of issues to resolve is how the divested shares will be valued and who will buy them.

Last year, Freeport offered a 10.64 percent stake in PT-FI that valued the mine at $16.2 billion while the government counter-offered at $630 million. Freeport believes that any Grasberg valuation should include the mineral resource, while Indonesia maintains that resource is essentially held by the country and not the mine operator.

"There's more reserves there than up to 2041 - these aren't theirs," said Jonan on Tuesday.

Freeport has to sell 41.64 percent of PT-FI to reach the divestment target, adding to a 9.36 percent share the government already holds.

Indonesia hopes that the divestment would be made in one block rather than spread out and would be completed by the end of 2018, said State Owned Enterprise Minister Rini Soemarno on Thursday.

On Wednesday, Soemarno said a state-owned mining holding company involving "several" state companies could take that remaining stake, and that an independent company will be appointed to calculate the divestment valuation.

According to Fajar Hari Sampurno, head of mining, strategic industries and media at the State Owned Enterprise Ministry, the government is forming a consortium involving the central government and regional administrations to purchase the stake.

"The consortium will look for funding sources - it could be from equity, loans, obligations (or) pension funds," Sampurno said.

Under Indonesian law, the central government would have the first claim to the PT-FI stake, followed by the country's regional governments. State-owned enterprise or regional government enterprises would be next in line followed by private companies or a public offering for the stake.

The divestment agreement also raises questions over the future role of Rio Tinto (>> Rio Tinto Limited) (>> Rio Tinto) at Grasberg. Under a joint venture formed in 1996, Rio has a 40 percent interest in PT-FI's Grasberg contract, which entitles them to a 40 percent share of all production after 2022.

Freeport CEO Richard Adkerson said on Tuesday that "PT-FI shares are what we're talking about with divestment," and that after 2022 "PT-FI will retain its 60 percent interest in the joint venture."

Shares of Freeport, the world's biggest publicly listed copper miner, have dropped 6.3 percent in the two days since the announcement, closing at $14.56 on Wednesday.

(Writing by Fergus Jensen; Reporting by Jakarta bureau; Editing by Christian Schmollinger and David Evans)

By Fergus Jensen and Cindy Silviana

Stocks treated in this article : Freeport-McMoran, Rio Tinto Limited, Rio Tinto