The Australians needed 11 runs from the last over with two wickets in hand but Shankar, playing only his sixth ODI, kept his nerves to pick a wicket off his first and third balls in the day-night game in Nagpur.
Skipper Virat Kohli, who struck 116 in India's modest total of 250, asked Shankar to bowl the final over ahead of the regular Kuldeep Yadav, and he was rewarded amply for his move.
The Aussies were bowled out for 242 off 40.3 overs with Marcus Stoinis top-scoring with 52.
It was the 500th win in one-day internationals for India.
The visitors were off to a steady start with openers Aaron Finch (37) and Usman Khawaja (38) putting on 83 runs before being dismissed in successive overs.
Glenn Maxwell (18) saw his stumps being uprooted after a ball from Kuldeep Yadav sneaked from under his bat.
But it was the run-out of Peter Handscomb who looked set for a big score that hurt the visitors hard.
Handscomb, who made 48 off 59 balls, tried to take a risky single but Ravindra Jadeja made no mistake in hitting the stumps.
A double-strike by Jasprit Bumrah (2-29) turned the game around for the Indians who ensured there was no let-up in the pressure on the visitors.
Earlier Kohli smashed his 40th century on a challenging pitch that seemed to aid bowlers.
Kohli hit 10 fours in his 120-ball knock and held anchor after Australian captain Finch had elected to bat.
The Indians got off to a rocky start, losing openers Rohit Sharma and Shikhar Dhawan (21) early in the innings.
Sharma (0) top-edged off Adam Zampa and Dhawan (21) was given out leg before wicket after Australia's appeal was upheld on review.
India had no such luck as Ambati Rayudu's decision to appeal against the on-field umpire's lbw decision was turned down, the hosts reduced to a shaky 75-3.
Kohli, the world's top-ranked ODI batsman, went for the counter-attack, hitting two fours off the last two balls of the 18th over by Zampa to underline his top form.
The 30-year-old skipper timed his innings perfectly, stitching a 81-run partnership with Shankar, who impressed during his 41-ball 46 before being run out by Zampa.
Zampa struck again soon after, dismissing Kedar Jadhav (11) and Mahendra Singh Dhoni (0) off successive balls to stun the home crowd into silence.
But Kohli looked unfettered at the other end, reaching his 40th ODI century with a four over backward point.
The flamboyant captain removed his helmet and raised his bat to acknowledge the applause from the crowd and the dressing room.
Kohli's innings ended when he holed a simple catch to Stoinis off Pat Cummins who picked up four late wickets.
India beat Australia by eight runs to take 2-0 up in the five-match series.