Needing 41 to win, England lost three quick wickets to be reduced to 3-8 before Ian Bell (28) and Nick Compton (9) saw the team home.
India began from their overnight score of 9-239 needing a miracle to save the Test with Ashwin also eyeing his second Test hundred but could only add eight runs.
The England reply began in bizarre fashion as Alastair Cook (1) came down the wicket to Ashwin (2-31) in the first over and was stumped.
Ojha got into the action in his second over when he trapped Jonathan Trott (3) plumb in front with an arm ball that came into the right-hander.
India’s hopes of an improbable win were further boosted when Ashwin induced an edge off Kevin Pietersen (0) in the next over with MS Dhoni taking a sharp catch behind the stumps.
With the three in-form batsmen back in the pavilion, the pressure was on England but Bell found a couple of early boundaries and Compton was solid at the other end to ensure the victory.
This is the first time India has lost consecutive Tests at home since 2000 when they lost the two-match series to South Africa and the hosts have much work ahead if they are to level the series in the final Test that starts in Nagpur from Thursday.
England will be delighted with their second victory of the series that came on the back of good batting and bowling displays.
INDIA 1st innings 316
England 1st innings 523 (A.Cook 190, J.Trott87
India second innings
G. Gambhir c (wkp.) Prior b Finn 40
V. Sehwag b Swann 49
C. Pujara run-out (Bell) 8
S. Tendulkar c Trott b Swann 5
V. Kohli c Prior b Finn 20
Y. Singh b Anderson 11
MS.Dhoni c Cook a Anderson 0
R. Ashwin not out 91
Z. Khan lbw b Finn 0
I. Sharma b Panesar 10
P. Ojha b Anderson 3
Extras: (b-8, lb-2) 10
Total: (all out; 84.4 overs 247
Fall of wickets: 1-86, 2-98, 3-103, 4-107, 5-122, 6-122, 7-155, 8-159, 9-197, 10-247 :
Bowling: Anderson 15.4–4-38-3, Finn 18-6-45-3, Panesar 22-1-75-1, Swann 28-9-70-2, Patel 1-0-9-0.
ENGLAND second innings
A. Cook stp Dhoni b Ashwin 1
N. Compton not out 9
J. Trott lbw b Ojha 3
I. Bell not out 28
Extras 0
Total (3 wickets, 12.1 overs) 41
Fall of wickets: 1-4, 2-7, 3-8
Bowling: Ashwin 6.1-1-31-2, Ojha 6-3-10-1.