The Board of Control for Cricket in India announced Dhoni's decision on Twitter, adding that Virat Kohli would captain India in the fourth test starting next Tuesday in Sydney.
The 33-year-old Dhoni, was captained the team 60 times, made no mention of his intention to retire during a lengthy and jovial news conference immediately after Tuesday's match.
In a later statement, the BCCI said Dhoni has retired from test cricket to concentrate on the shorter limited-overs and Twenty20 formats of the game.
"One of India's greatest test captains under whose leadership India became the No. 1 team in the test rankings, M.S. Dhoni, has decided to retire from test cricket citing the strain of playing all formats of cricket," the statement said.
Dhoni was batting on 24 at the end of the third test as he helped hold off the Australian bowling attack to earn the draw.
He has come under increasing scrutiny for his captaincy in the series against Australia, which the home side clinched Tuesday with a 2-0 lead.
A wicketkeeper-batsman, Dhoni made his test debut against Sri Lanka in Chennai in 2005, a year after playing his first one-dayer. He has since scored 4,876 runs at an average of 38.09 with six centuries and 33 half-centuries.
Dhoni has also taken 256 catches and 38 stumpings, as well as becoming the first Indian wicketkeeper to take nine dismissals in a match — achieved in the just completed third test.
Dhoni took over from Rahul Dravid as India captain in 2007 and led the side to 27 wins, 18 losses and 15 draws.
He was also in charge when India assumed the No. 1 test ranking in 2009, which it held for two years.
Wriddhiman Saha is to be named India wicketkeeper for the fourth test after standing in for the injured Dhoni in the first test in Adelaide.
"BCCI while respecting the decision of M.S. 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 BCCI statement said.
Dhoni is enormously popular in India and was this year ranked by Forbes magazine at 22nd in its list of the world's highest paid athletes, with estimated total earnings at $30 million, mostly from endorsements.
Former India great Sachin Tendulkar was among those who praised Dhoni on Twitter.
"Well done on a wonderful career in test cricket @msdhoni. Always enjoyed playing together. Next target 2015 WC my friend!!" wrote Tendulkar, referring to next year's Cricket World Cup in Australia and New Zealand in which Dhoni will likely play.
Former England captain Michael Vaughan tweeted "Love the way @msdhoni plays the game ... But it's now the right time for @imVkohli to take the Indian Test team in a new direction....."
Former India captain Sourav Ganguly said during the Melbourne test that he wondered whether Dhoni was still able to bring out the best in his test teammates.
"It's not just these two matches, it's for a while now," Ganguly said. "He just hasn't really got the team going at test-match level. The record he has in one-day cricket, he's a good captain. But in test conditions overseas, it's just fallen away a bit."