The all-rounder had looked uncomfortable for some time as he tried to stretch out in between balls, and was left hobbling during one run before eventually going off.
But having left the field with England 491-4, Stokes was back after India took three wickets in quick succession, returning with the hosts on 528-7.
An outstanding batting performance had left England in a commanding position, largely thanks to a century from Joe Root, who moved up to second on the all-time list of test run scorers behind Sachin Tendulkar.
Stokes' half-century followed his five wickets as India was all out for 358 on day 2.
His retirement came after India's Rishabh Pant retired hurt on day one with a foot injury and returned on day 2.
England leads the five-match series 2-1.
___
James Robson is at https://twitter.com/jamesalanrobson
Credit: AP
Credit: AP
Credit: AP
Credit: AP