Media playback is not supported on this device
The Northern Irishman came third on 5-2 favourite Box Office in his final race, won by 9-1 shot Brother Tedd.
McCoy, 40, had earlier finished third on Mr Mole behind winner Special Tiara in the AP McCoy Celebration Chase.
An emotional McCoy said: "It's amazing. I've been so lucky all my life. I'll never forget this day."
McCoy, who has ridden more than 4,300 career winners, added: "I want to thank everyone for coming. All my family were here and it's very special. An unbelievable day I'll never forget.
"There were tears coming back on Box Office. There were nearly tears going out on Box Office.
"I feel very lucky I have ended my career in one piece."
Discussing his record-breaking career, he added: "Someone's going to ride more winners than me. All records get broken. I hope I'm dead, though."
Jockeys formed a guard of honour amid huge cheers as the rider was honoured at the Surrey track.
Colleagues lifted the Arsenal supporter as he collected the champion jockey's trophy for a 20th and final time, from former Gunners striker Ian Wright.
The terraces around the parade ring were packed as a capacity crowd of more than 18,000 gathered, and a rendition of "For he's a jolly good fellow" rang around the stands.
Wright paid tribute, adding: "AP McCoy is made of something else altogether. For 20 years he has been at the top of his game, riding winners, week in, week out. I can think of no other sportsman or woman who can match his record."
McCoy has ridden in more than 16,000 races and suffered an estimated 1,000 falls in a remarkable career.
He did not compete in the feature race, the Bet365 Gold Cup, which was won by 17-year-old jockey Sean Bowen on Just A Par.
Bowen, tipped as a potential future champion, was completing a double on the day after victory on Lil Rockerfeller in the opener.
But there was a sad note to the afternoon for Just A Par's trainer Paul Nicholls when Rolling Aces died following the second race after collapsing on the walkway when returning afterwards.
AP McCoy missed out on a winner but was saluted by a sell-out crowd as the 20-time champion jockey ended his racing career at Sandown.