Gambhir, who played a key role in two of India's World Cup triumphs, will play his final domestic Ranji Trophy game for his home team Delhi starting Thursday.
The 37-year-old Gambhir, an attacking yet compact left-handed batsman, accumulated 4154 runs in 58 Test matches since making his debut in 2004 against Australia.
He also represented India in 147 one-day internationals and 37 Twenty20 matches.
But Gambhir, who formed a successful opening pair with Virender Sehwag untill 2012, started to lose favour with the selectors and last played a Test against England in 2016.
"The thought has been with me day and night...it has accompanied me to practice sessions, mocking at me like a menacing bowler," Gambhir said in a video message on social media.
"Each time I got out playing for India, or KKR (Kolkata Knight Riders) or Delhi Daredevils, this thought would turn into a sharp disturbing noise and walk with me all the way to the dressing room shouting that 'it is over Gauti'," he added.
Gambhir was part of India's 2007 win at the inaugural World T20 and played a pivotal role in the team's 50-over World Cup triumph in 2011.
The Delhi native, who was part of the Indian team that rose to the number one Test spot in 2009, led Indian Premier League (IPL) side Knight Riders to two titles in 2012 and 2014.
"This may sound a little wishful but I've seen wishes come true. Two World Cups, highest run-getter in the final of both of these games is the stuff dreams are made of," Gambhir said.
"Somewhere on the top is being the No. 1 Test team in the world. A trophy, I'll look at very fondly, is the one I got for being awarded the ICC best Test batsman of the year in 2009. For a purist like me, it is a reward for somewhat knowing where my off stump was.
"The historic series win in NZ (New Zealand) and the CB series in Australia will be reflected upon fondly. But I do hope the current Indian team Down Under can overshadow our feats."
Gambhir went on to thank his coaches, teammates and family members for standing by him and said his most meaningful partnership was with the supporters of Indian cricket.
He recently turned to commentary, sharing the mike with legends of Indian and Australian cricket during India's three T20 matches in Australia.