Warne, 37, told a packed news conference in Melbourne on Thursday he was quitting to spend more time with his children and to pursue a new career, possibly as a commentator.
"I'm going to retire at the end of the Sydney Test," he said. "It's been an unbelievable journey...but my time is now."
Warne, who retired from one-day internationals in 2003, is the world's leading Test wicket-taker and arguably the most famous cricketer since his compatriot Don Bradman.
He has taken 699 Test scalps and is poised to become the first man to reach the once-unimaginable 700 figure during the fourth Ashes Test in his home town of Melbourne next week.
Warne revealed he would probably have retired after the 2005 Ashes in England if Australia had won the series, but said defeat inspired him to play on to help his country regain the urn.
"There was still some unfinished business," he said. "Getting the Ashes back was my mission and I couldn't have worked the script better."
"I sit here today with every single trophy in the Cricket Australia cabinet so I retire a happy man."
"I'm going out on top and on my terms, I think I've earned that right. I think I'm still bowling well enough...but this is the right time for me."
Warne said he had made up his mind to retire after helping Australia regain the Ashes from England in Perth on Monday, December 18. Warne took the final wicket that gave Australia an unbeatable lead with two matches still to play.
He discussed his plans with Australian captain Ricky Ponting and sought counsel from former skippers Ian Chappell and Richie Benaud before breaking the news to his three young children and his former wife Simone, who he continues to live with despite their divorce.
Warne is largely credited with revitalising the dying craft of wrist-spin after an era dominated by fast bowlers.
He made an inauspicious start to his career, taking one wicket for 150 on his Test debut in January 1992 in Sydney against India, but quickly set about tormenting the world's best batsmen and re-writing the record books over 15 years.
"I don't think I could have asked my career to be any better," he said.
"I never dreamt my cricket career would go as well as it has."
"I've been very lucky to play in an era when Australian cricket was so successful and to play with so many great players."
Warne's farewell match in Sydney starting on January 2 will be his 145th Test appearance and his last official match in Australia at any level. He does intend to honour the final two seasons of his contract with English county Hampshire.
Dogged by sex, drugs and gambling scandals throughout his career, Warne was never far from controversy, but his performances on the field never waned.
He said his proudest moment was making his Test debut for Australia and his favourite Test was this month's second Ashes match in Adelaide, where Australia pulled off an extraordinary last-day win after he ripped through the English batting.
He nominated Brian Lara of the West Indies and India's Sachin Tendulkar as the two best batsmen he played against and said he wanted to be remembered only as a bowler who always tried his best.
"I don't think I could have given any more, I gave absolutely everything to the game," he said.
"I'll probably miss it... but rather than be sad about it I'd actually be happy about it."
"I had a lot of fun and I think I've made cricket more enjoyable."
"People have turned up, I like to think that I've given them entertainment and I've tried my guts out every single time."
Warne's place in history is already assured. He was chosen by Wisden as one of the five best players of the 20th century, along with Bradman, Englishmen Jack Hobbs and West Indians Viv Richards and Gary Sobers.
His retirement has stunned the cricket community and tributes were flooding in from around the world in the knowledge that his absence will leave a void in the game that may take years to fill.
"There are a generation of Australians who were privileged enough to see Bradman," Cricket Australia Chief Executive James Sutherland said.
"We are the generation that will always say we were privileged to see Warne."