Stirling top-scored with 70 and Balbirnie made a patient 68 to drive a tricky chase for Ireland in a hard-fought series that comes after their whitewash in the two Twenty20 matches.
“All the batters are aware how good their (Afghanistan) spinners are,” said Balbirnie, who was named man of the series for his 215 runs in the series.
“I just kind of knew my game, we watched a lot of their footage.”
Left-arm wrist spinner Zahir Khan took two wickets including skipper William Porterfield for 17.
Leg-spinner Rashid Khan, who made an unbeaten 35 with the bat, trapped Stirling lbw but Balbirnie stood firm during a 46-run partnership with Kevin O’Brien, who made an unbeaten 33.
Ireland had a little stutter in the end with Balbirnie bowled by teenage spinner Mujeeb Ur Rahman and George Dockrell out for a first-ball duck off Mohammad Nabi.
Stuart Poynter hit the winning boundary.
Earlier Afghanistan skipper Asghar Afghan struck a gritty 82 to bring Afghanistan respect after they were left reeling at 50 for four.
Afghan, who made 75 and 54 in the previous two matches, put on 76 runs with veteran batsman Nabi, who made 40, to revive the innings.
He then held strong with Rashid at the other end to manage 65 runs for the seventh wicket before retiring hurt. His 111-ball stay was laced with six fours and two sixes.
“It was a good series. We are targeting the World Cup, so we made changes in every match,” Afghan said.
“Top order’s a concern, (but) the Test match should offer an opportunity.”
The two teams will play a one-off Test starting March 15 in Dehradun.