Ireland fell agonisingly short of a first-ever win over a Test-playing nation in Dublin as the opening RSA Insurance one-day international against Pakistan ended in a tie.
O'Brien attempted to complete the job, as he thrashed an unbeaten 84 from 47 balls, but the hosts had to be content with a draw. The hosts had still needed 105 when Stirling departed, in a match reduced to 47 overs by rain, but Kevin O'Brien's lusty strokeplay took it to the wire as Ireland finished on 275 for five in reply to Pakistan's 266 for five.
It meant Mohammad Hafeez's own century earlier in a total improved to 275 on the Duckworth-Lewis Method because of the rain - and his two wickets, were not enough for Pakistan. Stirling immediately set about his task driving Mohammad Irfan in the first over. While skipper William Porterfield fell meekly, chipping Hafeez to Asad Shafiq at mid-wicket, after a 66-run opening stand, his departure hardly inhibited Stirling.
The ease of the opener's timing was the feature and when Pakistan eventually turned to Ajmal, curiously waiting until the 23rd over, Stirling showed his subtlety with a pair of swept boundaries. Better was to come when Stirling launched him into the stands off one knee.
Ed Joyce provided an astute presence in a 96-run stand until he played down the wrong line to Hafeez. Ireland were 158 for two and sought to press home their advantage by sending in Kevin O'Brien. Stirling was soon celebrating his fifth ODI century but fell soon after and Ireland's hopes remained with his brother Kevin. With Trent Johnston they reduced the ask to 15 from the final over and an O'Brien six from the third ball had the home fans jumping only for their side to fall just short.
Earlier, Hafeez defied the rain delays to keep his composure and post his fifth ODI century. He initially had to rescue the innings from a pedestrian start after the Pakistan openers appeared paralysed by a combination of the Dublin cold and Tim Murtagh and Johnston's tight lines.
Ireland were rightly enthused, despite the weather which at one point brought hail, until Hafeez and Shafiq took control with a 188-run stand. The pair initially targeted Ireland's second-stringers, with Kevin O'Brien and Stirling's combined 10 overs costing 74, to break the early shackles.
They worked around a further two rain delays before reaching their 100 stand from 122 balls and Shafiq looked set for his maiden ODI century, after passing his previous best of 78, only to miscue a lofted drive off Alex Cusack to Johnston. Hafeez did bring up three figures in the next over when he pushed his 102nd ball to deep mid-wicket for two.
The right-hander's only blemish was to run out his skipper Misbah-ul-Haq, who had not faced a ball, after Nasir Jamshed had departed by chipping Kevin O'Brien to a diving Murtagh in the deep. But Hafeez remained until the end, lifting Johnston over the pavilion for a second time, which proved crucial.