Chasing a stiff target of 322 for a win at the asking rate of 6.44 per over, Pakistan scored 322 for six in 49.5 overs to improve upon their previous best chase of 319 for seven at Ahmedabad in 2005.
Reeling at 174 for 4, it looked all over for the visitors because at that stage Pakistan needed a run rate of 7.01 per over.
But in came Misbah-ul Haq and the visitors came alive.
The Indian bowling suddenly started looking pedestrian as the two took over and started dictating the proceedings.
Scorecard | Photo gallery
Man-of-the-match Younis Khan, dropped when he was 72 by Yuvraj Singh at mid on off Harbhajan Singh, went ballistic as he sent Sourav Ganguly and Harbhajan for two towering sixes and raced his way through his third ODI century, and first against India.
His previous best against India was 81 at Rawalpindi in 2005. He and Misbah added 102 runs for the fifth wicket in 76 balls to bring the visitors near to victory.
But at this crucial moment, Younis was bowled by Zaheer Khan.
Younis' 117 came off 110 balls and were studded with two sixes and nine fours.
Next over R.P. Singh clean-bowled Misbah, who was 49 (44 balls, 3 x4) at that time and the visitors slumped to 283 for 6 but Afridi and Sohail Tanvir frustrated the limited India attack and added 39 runs in 19 balls to dash the host team's hope of going 2-0 up in the five-match series.
Afridi's 29 included two sixes and three boundaries while Sohail remained unbeaten on 14 (10 balls, 2x4).
Today's win in a way erased the painful memories of Pakistan's earlier two losses at the venue -- against New Zealand and South Africa in the Champions Trophy last year.
Electing to bat, India scored 321 for 9 in 50 overs with Sachin Tendulkar scoring 99.
The Indians went into the game with four bowlers and the inadequacy in the bowling showed as Pakistan snatched a win from the jaws of defeat.
Pakistan started briskly as openers Salman Butt and Kamran Akmal putting up 38 runs off first five overs. However in the sixth over, Akmal got a bit too ambitious and tried to blast R.P. Singh only to be caught at point by Yuvraj. The wicket keeper-opener made 13 off 19 balls with the help of one boundary.
In form Salman Butt, playing his 38th ODI, was joined by his vice-captain Younis Khan and the two kept the scoreboard moving at a good pace and added 43 runs in 9.2 overs for the second wicket.
As Pakistan hoped for a big stand, they suffered a big jolt when Butt departed. The opener dragged Irfan Pathan's outside the off stump delivery on to his stumps and the visitors were two down for 81 in 14.5 overs.
The loss of Butt rattled Pakistan and veteran Mohd. Yousuf along with seasoned campaigner Younis Khan virtually shut down the run rate.
The two most experienced batsmen of the visiting side just could not accelerate the run rate which was the need of the hour and they just managed 13 runs in the five overs of the last power play.
Thirty-three-year-old Yousuf, playing his 249th ODI, was tentative throughout his stay while 29-year-old Younis Khan, in his 158th ODI, was just not able to get out of his shell to get the scoreboard moving.
In the 21st over, Dhoni brought in Harbhajan and the Punjab spinner struck a vital blow for India in his second over when he bowled his 'doosra' which baffled Yousuf who charged out of the crease just to see the ball moving away from him and Dhoni did the rest as the batsman was left stranded. Yousuf made 12 off 25 balls hitting one boundary.
With three wickets down for 105 runs in 22.5 overs, the visitors were in a dire straits but then a rollicking 69-run fourth wicket stand between Younis and skipper Shoaib Malik followed.
Younis came out of his shell, started hitting the bowlers all over the park. He blasted Ganguly for a six and then raced to his 29th ODI fifty, his fourth against India.
But, Malik fell in a bid to accelerate the run rate, caught at long on by Pathan off Harbhajan. The skipper made 25 (28 balls, 2x4).
Earlier, spearheaded by master blaster Sachin Tendulkar (99), and his 173-run second wicket partnership with Gautam Gambhir (57), India piled up a massive 321 for nine in their allotted 50 overs. The Indian top order, barring Sourav Ganguly, and lower order clicked well with Harbhajan Singh blasting an unbeaten 20-ball 38 which included two huge sixes off Rao Ifthikhar to take Indian score well past 300.
The hosts were served well by the tailenders who added 42 runs in the last five overs after a mini middle order collapse.
The score of 321 is the second highest total in this ground so far, the highest being 339 for 4 by Sri Lanka, also against Pakistan in 1997.
Hosts skipper Mahendra Singh Dhoni elected to bat after winning the toss but Ganguly's dismissal in the third ball of the first over created some doubts about Dhoni's decision but they were laid to rest as Tendulkar and Gambhir got together to shred the Pakistan bowling.
Pakistan opted to go into this game with four pronged pace attack replacing spinner Abdur Rehaman with seamer Sohail Tanvir and, when their spearhead Shoaib Akhtar castled Ganguly's middle and leg stumps, the decision to pack the attack with seamers seemed justified.
But, Tendulkar and Gambhir had other ideas as they demolished not only the pace but the part time spin attack.
The two took time to settle down and in the first few overs, runs came either through extras or due to poor fielding.
After three overs, Akhtar seemed to have lost his sting and Umar Gul, on the other hand, was also not able to penetrate the solid defence offered by the Indian duo.
Tendulkar, playing his record 404th one-dayer, soon got into his rhythm and Gambhir, seeing his senior partner in his elements at the other end, also started emulating the master blaster.
Tendulkar belted Gul for three successive stunning boundaries to race to his 86th ODI fifty. He first sent the bowler past short fine leg and then edged him past second slip to third man boundary and then slammed another four to leave the bowler bewildered.
Gambhir, though not as aggressive as his senior counterpart, kept the scoreboard moving with deft ones and twos and occasional boundary.
Akhtar looked flat and Gul stingless in their first spell and the next two seamers in Sohail Tanvir and Rao Ifthikar Anjum also could do nothing as the Indian duo looked well entrenched.
Tendulkar was in his elements as he sent the bowlers all over the park and Gambhir, as if taking a cue, started cutting and hitting. Pakistan captain Shoaib Malik came himself into attack but was torn apart by the Indian duo who took 31 runs off his three overs and Malik thought it wise to take himself off the firing line.
Shahid Afridi, who had best figures of 2 for 18 here on this track, came into the attack and Tendulkar greeted him with two super fours and in his next over hoisted him for a six over long off.
On the other end, Gambhir, playing his 34th ODI, raced to his 50, his sixth and first half century against Pakistan, and in the process scored 1000 runs in the shorter version of the game to become the 27th Indian to achieve this feat and India were looking all set for a huge total.
However at this stage, plot changed. Umar Gul was brought in for his second spell. His first five over spell had cost him 28 runs and this time he struck.
Tendulkar, who was all focused, tried to run a full length delivery to third man only to see Kamran Akmal taking a superb diving catch.
The Mumbaikar made 99 runs off 91 balls which included one six and 13 hits to the fence.
This was the fifth time this year that the master blaster got out in his 90s and third time on 99. He was out against South Africa and later against England early this session on this score and today, he earned another distinction of being the only player to have got out thrice on 99 in ODI.
The 173-run second-wicket partnership came off 153 balls in 127 minutes.
Gul struck in his next over again as he had well set Gambhir caught by Afridi at mid wicket when the batsman was on 57 (68 balls, 7x4) and India were 186 for three then.
Virender Sehwag and Yuvraj Singh added 53 runs for the fourth wicket before Sohail Tanvir clean-bowled the former.
Sehwag made a sedate 25 off 31 balls hitting one boundary.
Gul finished his spell conceding 56 runs for two wickets and then Akhtar came back into attack and conceded four wides in his over but he steadied himself to take two wickets -- that of skipper Dhoni (4) and Irfan Pathan (7).
In between, Sohail Tanvir trapped Robin Uthappa leg before wicket before the Karnataka batsman could open his account.
Akhtar had a better second spell in which he conceded 18 runs while taking two wickets.