The shock announcement came minutes after Dhoni addressed reporters in the wake of India’s draw in the third Test against Australia in Melbourne, which conceded the four-match series 2-0 to the hosts.
The 33-year-old will be replaced by Virat Kohli who will lead the team in the fourth Test against Australia in Sydney on January 6.
Dhoni made his Test debut in 2005 against Sri Lanka and made 90 appearances over his career, scoring 4,876 runs with an average of 38.09.
He made six centuries and 33 half-centuries in 144 innings in Test cricket.
The secretary of the Indian cricket board paid tribute to Dhoni after his 90th and now??final Test appearance in Melbourne.
Sanjay Patel said:??”One of India’s greatest Test captains under whose leadership India became the??number one team in the Test rankings, MS Dhoni has decided to retire from Test??cricket citing the strain of playing all formats of cricket.
“MS Dhoni has chosen to retire from Test cricket with immediate effect in??order to concentrate on ODI and T20 formats.
“BCCI, while respecting the decision of MS Dhoni to retire from Test cricket,??wishes to thank him for his enormous contribution to Test cricket and the??laurels that he has brought to India.”
The announcement comes just weeks before India are due to begin their defence of the 50-over World Cup trophy that Dhoni lifted on home soil in 2011.