After winning the toss, Ireland could only post 229 in 48.1 overs with in-form Paul Stirling top-scoring with 51 and Ed Joyce contributing 42.
Afghanistan were reduced to 25-2 but Shah's 108 not out and Samiullah Shenwari's unbeaten 62 secured the win.
The duo's 133-run partnership saw the Afghans home with eight balls to spare.
Tim Murtagh (1-36) and Stuart Thompson (1-38) had given Ireland early hope of defending their modest total with the early wickets of Mohammad Shahzad and debutant Najeeb Tarakai but skipper Asghar Stanikazai (39) settled the Afghanistan nerves with a third-wicket stand of 73 with Shah.
Some tight bowling from spinners Andy McBrine and George Dockrell boosted Irish hopes for a time as they bogged down the Afghanistan batting before Shah and Shenwari produced the crucial partnership.
"I think we were 20 or 30 runs light with the bat," said Ireland skipper William Porterfield.
"We gave it a good fight, but that was a fantastic knock from Rahmat which saw them over the line."
Stirling reached his fourth half-century in his last five one-day internationals from 55 balls after being dropped at slip on nought.
But as teenage leg-spinner Rashid Khan took 4-29 and went past 50 wickets in his 26th one-day match, Ireland lost their last seven for only 59 runs.
Afghanistan took a 2-0 lead in the series but impressive batting from Stirling helped the Irish force Friday's decider in Greater Noida.
"I'm pleased with the character we've shown after going 2-0 down, and the way the team fought to the end today," added Porterfield.
Kevin O'Brien was ruled out of Friday's game by a hamstring injury after hitting an unbeaten 72 in Wednesday's game.
O'Brien will also miss the four-day Intercontinental Cup between the teams which starts on Tuesday.
Afghanistan clinched a 3-2 victory in the one-day series against Ireland as Rahmat Shah's century helped secure a seven-wicket win in the decisive match.