"I came back to NZAS in 2018 to lead a team that runs one of the best operations in New Zealand and around the world. The last few years have been very challenging and I am proud of what the team has achieved over that time."
Hamilton's time at the smelter has been dominated by at-times tense negotiations with the Government and electricity company Meridian about the smelter's future.
In 2019, Rio Tinto announced a strategic review of its New Zealand operations - made up of its almost 80 per cent stake in the smelter - with Hamilton claiming the company needed tens of millions of dollars a year in lower electricity and transmission prices.
Eventually a deal was struck with Meridian, which was sufficient to see the smelter remain open until at least 2024, but talks with the Government over transmission relief, after the two sides could not see eye to eye on clean up plans for the smelter, which is home to thousands of tonnes of toxic materials.
Hamilton said he was "inspired by the team's incredible commitment to safety, to looking after each other and ability to keep focusing on making some of the best, lowest carbon, purest aluminium in the world. I leave in confidence that the Tiwai team will continue to perform at the highest level."
Daniel van der Westhuizen, Rio Tinto's acting managing director of Pacific operations, said Hamilton had made a "significant contribution" to NZAS over 22 years.
"The smelter has been going through a very public period of transition, and Stew's commitment and leadership has been hugely valued throughout this time."
Hamilton's new role will see him reporting directly to Mercury chief executive Vince Hawksworth.
The role "will be integral to supporting the contribution Mercury makes to New Zealand's transition to a low-carbon economy", Hawksworth said in a statement.
"Stew is uniquely positioned in terms of the perspective he offers, and the experience he brings in operating hugely complex assets in a rapidly changing environment," said Hawksworth.
Hamilton will join Mercury, which is 51 per cent owned by the Government, in the third quarter of 2021.