Hours earlier on the fourth day, the Irish were facing the prospect of an innings defeat but they lost only three wickets in the final two sessions to reach stumps on 319-7 following on.
Even a draw would be a marvelous achievement for a country which was awarded Test status only last June.
O'Brien became the first player to score a Test century for Ireland and he was there at the close on 118 not out, with his 114-run partnership with Stuart Thompson (53) for the seventh wicket proving decisive. Tyrone Kane was with O'Brien on 8 not out.
Mohammed Amir shrugged off a nagging knee problem to be the pick of the bowlers, finishing the day with figures of 3-57 as he reached 100 Test wickets. The left-arm paceman's turbulent Test career was interrupted by a jail sentence by an English court and a five-year ban by the ICC for his involvement in a spot-fixing scandal in 2010.
Resuming their second innings on 64 without loss after being asked to follow on and still needing 116 more runs to make Pakistan bat again, Ireland slumped to 123-4 by lunch. When Amir removed Gary Wilson (12), caught by Haris Sohail in the slips, and Paul Stirling (11) was trapped lbw by Mohammad Abbas, Pakistan was close to clinching victory.
O'Brien's circumspect batting — his 118 has come from 216 balls and contained 12 fours — has ensured Ireland stay alive at Malahide.
Pakistan declared their first innings on 310-9 early on Day 3 after the first day was washed out.
First Published: May 15, 2018, 6:50 AM IST