Mr McEwan, who runs the retail bank at Commonwealth Bank of Australia (CBA) – the country's largest bank – will join the bank in the summer after Mr Hartzer returns to Australia in June to work for Westpac.
Mr Hartzer himself was hired by RBS from another Australian banking institution, ANZ, three years ago.
RBS confirmed there is likely to be a gap between the two men being in post, during which time Les Matheson, managing director for retail products at RBS, and Satyendra Chelvendra, who oversees consumer distribution, will run the retail business.
Group chief executive Stephen Hester said he will chair the retail bank's executive committee himself until Mr McEwan arrives in the UK.
Mr McEwan will report to Mr Hester, and while he will not sit on the company's board he will be a member of RBS's executive committee.
Mr Hester said: "Ross McEwan brings a wealth of leadership and banking experience to this important job.
"The retail bank is at the heart of our customer activities and central to the future value and success of the RBS Group.
"We have more to do to fulfil the full potential of the retail business in a changing banking market.
"We all look forward to working with Ross as he leads the business to face these opportunities and challenges."
A New Zealander, Mr McEwan has run Commonwealth Bank's retail bank since 2007, but last year he lost out on the top job at CBA to Ian Narev, its head of business banking.
For RBS the hope is that Mr McEwan, who currently oversees Australia's biggest retail banking operation with some 10 million customers, will bring with him experience in improving customer service standards, which has been a big feature of competition in the Australian market in recent years.
The Australian banking market was one of the few in the English-speaking world to emerge from the financial crisis relatively unscathed.
Mr Hester said that under Mr Hartzer, RBS's retail bank has become an "impressive contributor" to the group.
RBS has turned its attentions to improving standards at its retail bank since Mr Hester took over, after a period of relative neglect as RBS targeted expansion in the years before the credit crunch.
The retail business will become increasingly important to the 82% state-owned bank as Mr Hester cuts back its investment bank and many overseas operations.
RBS has already signalled it wants to continue expanding its mortgage book in the coming year, even as others cut back.
Mr McEwan's pay at RBS has not been disclosed but the bank said it would make an announcement before he joins.
Mr McEwan originally joined the Commonwealth Bank as executive general manager for retail sales in December 2006. Before that he was with the ASB group in New Zealand for four years.