Debutant Hanuma Vihari scored 56 to help the tourists trim the lead to 40 after resuming the day on 174/6.
Ravindra Jadeja prevented a far bigger lead with 86 not out after India resumed on 174-6.
Cook — who will retire from test cricket at the end of his 161st match — came through a shaky start to maintain his hopes of a farewell century at the Oval.
Mohammed Shami, however, sent back his opening partner Keaton Jennings with a beauty.
Jadeja got Ali soon after, bowling him through the gate as the ball spun a mile, after kicking up from the rough.
England captain Joe Root played fluidly to reach the close on 29 not out alongside the man he succeeded as skipper.