The all-rounder, who could miss next week´s second Test of a five-match series at Lord´s because of a court trial on a charge of affray starting Monday, took two wickets in an over including Kohli.
Stokes ended the match when he had Hardik Pandya (31) caught at first slip by Alastair Cook, with India bowled out for 162, having been set 194 to win.
Pandya´s exit left Stokes with innings figures of four for 40 in 14.2 overs.
However, fellow England all-rounder Sam Curran was named man-of-the-match after starring with both bat and ball.
That England had a target of 194 to defend was largely down to the 20-year-old Curran´s 63, his maiden Test fifty in just his second match at this level rescuing the hosts from the depths of 87 for seven.
Curran´s innings came just a day after the Surrey left-arm swing bowler´s Test-best haul of four for 74 during India´s first innings of 274.
Saturday´s play started with the match on a knife edge.
India were 110 for five — still 84 runs shy of victory — with England needing five wickets.
Given the sunny overhead conditions in Birmingham, the only certainty then was the match would finish with more than a day to spare.
Kohli was 43 not out and wicket-keeper Dinesh Karthik unbeaten on 18.
England knew they needed early strikes and Anderson, their all-time leading Test wicket-taker, duly obliged when he had Karthik (20) caught low down by Dawid Malan at second slip off just the sixth ball of the day.
It was a morale-boosting moment for Malan, who had dropped three slip catches this match, including flooring Kohli on 21 and 51 during the star batsman´s first-innings 149 — his maiden Test century in England.
New batsman Pandya played several solid defensive shots before driving Stuart Broad down the ground for a textbook four — a boundary greeted with huge cheers by the large contingent of India fans in the crowd.
Kohli then completed an 88-ball fifty when he glanced Anderson down to fine leg, the fourth four of his innings sparking chants of “Kohli!, Kohli!, Kohli!” from spectators.
Pandya kept the runs coming with two more boundaries off Broad — a straight drive followed by a clip past midwicket.
India were 141 for six, needing 53 more runs to win, when paceman Stokes had star batsman Kohli lbw for 51 with just his third ball of the day.
Kohli reviewed but experienced Pakistan umpire Aleem Dar´s decision was upheld.
Three balls later, Stokes had Mohammed Shami caught behind for a duck.
India now looked to Pandya and Ishant Sharma to take them to just their seventh win in 58 Tests in England.
But when Sharma was lbw to leg-spinner Adil Rashid´s googly for 11 — albeit England had to first review New Zealand umpire Chris Gaffaney´s original not out call — India were 154 for nine and needing a further 40 runs for victory.
Pandya, with just Umesh Yadav for company, launched Stokes over extra-cover for four before refusing easy singles to spare the No 11 from facing up.
But Pandya´s resistance ended when he edged Stokes and Cook, after a match of several dropped catches in the slips, made no mistake.