Amir's three wickets earlier in the day had put Pakistan into a position from which an innings win seemed entirely possible - even likely - but O'Brien and Stuart Thompson combined for a 114-run rearguard that not only pushed Ireland in front and burnished local pride, but allowed them to sleep on the possibility of another famous upset. Imam-ul-Haq, the debutant opener, and Babar Azam fashioned the significant partnership Pakistan needed to avert disaster after they had slipped to 14 for 3 chasing 160.
Imam has already dealt with the pressure of expectation - his uncle, Inzamam-ul-Haq, is one of Pakistan's greatest batsmen, as well as the chief selector - and he played an innings of calm authority to record his maiden half-century, characterised by composure and sound shot selection.
Kevin O'Brien failed to add any runs to his overnight score of 118 before swinging at a wide delivery from Mohammad Abbas and edging to first slip.
Abbas wrapped up the innings, and his second five-for in Tests, when he bowled Rankin (6) and Tyrone Kane (14) off inside-edges - but it was then Ireland's pacemen who came to the fore.
Pakistan eventually closed out the game, securing 160-5 to take the inaugural test match, with Imam finishing 72 not out to cap off a fine debut display for him.
"They have a quality line-up but if we had got another couple and break that partnership, then it's completely game on", added Porterfield, reflecting on the missed opportunity to cause another major shock in world cricket.
The Ireland and Pakistan players together at Malahide.
Babar, who was dropped on 9, was run out 20 runs short of the target.
70 officers and deputies escort fallen cop's son back to school
His father Rob Pitts, a 16-year veteran with the force, was tragically killed on May 4 in a shootout aged 45. Wolfe also died of a gunshot wound, but officials haven't yet released details about how he was shot.
The now 26-year-old Amir's cricket career nearly came to an end following his involvement in a spot-fixing scandal during a 2010 Test against England at Lord's.
The Irish can be proud of taking Pakistan all the way in their first match in cricket's longest format after being awarded test status last June, especially having been bundled out for 130 in their first innings in the grounds of Malahide Castle, just north of Dublin.
With Pakistan requiring 160 to win, Ireland sensed the possibility of a sensational victory, quickly reducing their opponents to 14/3.
Now Sarfraz Ahmed, if only for a few hours perhaps, has to contemplate whether he made a wise move by becoming the first Pakistan captain to enforce a Test follow-on in 16 years. That's always been known to be there but Test cricket is Test cricket for a reason, it's there in the name, you did get tested and we were after the first innings.
Murtagh gave Ireland a flying start with the ball on the final day.
O'Brien was just the fourth player to reach three figures in his country's first men's Test, with Australia's Charles Bannerman, Zimbabwe's Dave Houghton and Bangladesh's Animul Islam the others.
Ireland also had a chance to become the third team, after England and India, to win a Test after following on.
- Seattle's new 'head tax' blasted by city's mega-corporations
- Manchester City's record breaking season by the numbers
- Slain trooper to be honored at Peace Officers Memorial
- Pakistan played a role in 26/11 Mumbai terror attacks: Nawaz Sharif
- Israel faces growing backlash after dozens killed in Gaza
- China's ZTE says United States sanctions have crippled operations
- Tuesday is voting day on school district budgets
- Rage 2 Gameplay Trailer is here, The Wasteland is One Crazy Drug!
- Avengers: Infinity War smashes superhero box office record with £60m takings
- CIA Director's Confirmation in Doubt as Sen. McCain Cites "Disturbing" Torture Role