The 32-year-old made the surprise announcement just minutes after the test at Newlands ended in draw and after Amla had led a fight back to haul his team from a precarious position.
AB de Villiers will take over as captain for the last two tests against England.
“Naturally this decision is not an easy one but the more I think about it the more I believe I can be of greater value to the Proteas as a fully focused batsman and senior player at this time or rebuilding our team,” Amla told reporters.
“I will continue to give my all to the team.”
Amla said he had been considering quitting over the last fortnight, even before the start of the series against England and the loss of the first test by 241 runs in Durban last week.
“It’s a bit of relief,” he said.
Amla captained South Africa for 14 tests with four wins, six draws and four defeats. South Africa, despite being the top-ranked test nation, have not won in their last eight tests sketching back to more than a year and Amla’s form has suffered.
He scored 251 test runs in 2015 but seemed to have got right the balance of making runs and captaining the team with a double century on Tuesday as his stoical performance rescued his side from the possibility of going 2-0 down in the series.
“We respect Hashim’s decision and the manner in which he thought about it and then communicated with me. He still has a huge role to play in shaping the success of our team without the need for a leadership title. He is just that type of a person and we are very fortunate to have him in our stable,” Cricket South Africa chief executive officer Haroon Lorgat said.
South Africa lost the first test against England last week by 241 runs and play the next two in Johannesburg and Pretoria. The third test at the Wanderers starts on Jan. 14.
“It’s a bit of a shock. I haven’t got anything to say,” England captain Alastair Cook said reacting to the news.