Flanker Warburton, who led the Lions on tours to Australia in 2013 and New Zealand last summer, underwent neck and knee surgery last year and has not played for 12 months.
The announcement was made jointly by the Welsh Rugby Union and Warburton’s regional team Cardiff Blues.
Warburton said: “Unfortunately, after a long period of rest and rehabilitation, the decision to retire from rugby has been made with my health and well-being as a priority as my body is unable to give me back what I had hoped for on my return to training.”
Warburton won 74 Wales caps and captained his country a record 49 times after being appointed ahead of the 2011 World Cup.
His final match was a drawn third Test for the Lions against New Zealand in Auckland last July.
He returned to training with the Blues this summer after missing the whole of last season, but has now made the decision to call it a day.
The WRU and Blues statement read: “Since returning to pre-season with Cardiff Blues, it has become clear to Warburton that he wouldn’t be able to return to the high standards he has set throughout his career and has reluctantly made the decision to retire.”
Warburton added: “I cannot thank the Welsh Rugby Union and Cardiff Blues enough, who have gone beyond the call of duty in providing the support I received to help me get back on the field, for which I will be forever grateful.
“Since I first played aged 10 at Llanishen Fach Primary School, then Whitchurch High School and Rhiwbina Juniors RFC, I always dreamed of playing for my hometown club the Cardiff Blues, Wales and the British and Irish Lions.
“To look back on my career, I am extremely proud of what I managed to achieve.
“There are so many people who helped me along the way from schoolteachers, coaches, friends and family. I thank you so much for supporting my dreams and aspirations. I hope they too can take some pride from my career.
“I would like the make special mention of (Wales head coach) Warren Gatland. Without the faith he had in me and his unwavering support, I would never have had the career I was able to pursue.
“As one chapter finishes, another begins, which I will enter with the same level of passion and determination as the last.”
Warburton emulated England World Cup-winning skipper Martin Johnson in captaining the Lions on two separate tours.
Under his leadership, the Lions claimed a first Test series victory for 16 years when they beat Australia, and then drew the series against reigning world champions New Zealand a year ago.
He also steered Wales to the 2011 World Cup semi-finals - he was controversially sent off in the last-four clash against France - with Gatland appointing him as Wales skipper and Lions leader, after heading up the Australia and New Zealand tours.
Gatland said: “It is hugely disappointing that Sam has retired from the game.
“He is an outstanding rugby player and he has brought so much to the game, on and off the pitch.
“His leadership, attitude and demeanor, along with his performances, have placed Sam up there as one of the best and most respected players in the world.
“He finishes with a record that he should be extremely proud of and should look back on his career with huge pride.”