The 19-year-old Hameed was unbeaten on 62 at the close with Cook on 46 as England reached 114 without loss, virtually ruling out the prospect of an India win on the final day.
Hameed, whose parents originate from India, reached his half-century with a delicate late cut for four off leg-spinner Amit Mishra.
Day three: Pujara, Vijay lead India's strong reply against England
Right-hander Hameed, the youngest opener to play a test for England, was assured in his footwork against the spinners and handled the reverse swing from the fast bowlers without much trouble.
Leg-spinner Adil Rashid earlier picked up four wickets to help the touring side dismiss India for 488 and take a first- innings lead of 49 runs.
India's Ravichandran Ashwin made 70 to deny England a bigger advantage after the hosts lost two wickets in the early session and were reduced to 361 for six.
Ton-up Root, unbeaten Ali help England start strong against India
He along with wicketkeeper Wriddhiman Saha (35) added 64 for the seventh wicket to reduce the deficit.
Resuming on 319-4, Kohli and Rahane appeared untroubled, picking up singles and twos as well as occasional boundaries.
Rahane missed a straight delivery playing across the line to left-arm spinner Zafar Ansari and was bowled for 13, ending their 30-run partnership.
Kohli looked in fine touch and struck crisp boundaries in his 40 before the right-hander was out hit wicket, his back leg brushing the stumps as he tried to pull a Rashid delivery.
The 28-year-old stood in disbelief before trudging off with his team on 361 for six.
Saha survived nervous moments at the start of his innings and saw an edge off Ben Stokes go between wicketkeeper Jonny Bairstow and Cook at slip.
He was also hit on the grill of his helmet by fast bowler Chris Woakes before getting an edge to Bairstow off Moeen Ali.
Rashid took the wickets of local boy Ravindra Jadeja and Umesh Yadav to take his innings tally to four.
England captain Cook dropped number 11 batsman Mohammed Shami at slip off Stuart Broad and India adding another 29 runs for the final wicket.
Ashwin, who hit seven boundaries, was the last man out when he holed out at deep midwicket, giving off-spinner Moeen his second wicket of the innings.
COMMENTS
Comments are moderated and generally will be posted if they are on-topic and not abusive.
For more information, please see our Comments FAQ