While Joyce survived in the very first over due to wicketkeeper and captain Sarfraz Ahmed's lack of judgement, Porterfield was dropped by Azhar Ali in the third slip in the fifth over.
Pakistan had an injury issue of their own, with Amir having to leave the field in the final session with an injury to his left knee.
But with Mick Jagger, a lifelong cricket fan, among the crowd - the Rolling Stones play a concert at Dublin's Croke Park on Thursday - the openers gave Ireland some satisfaction in a day dominated by Pakistan.
"We're confident, we can take a huge amount of confidence".
"Whenever you're asked to follow on and you can go 60 for none at the close, that shows big balls".
Former England one-day global Joyce, at 39 the oldest Test debutant since Australia's Bryce McGain made his bow aged 36 in 2009, cashed in with some elegant shots including a cover-driven boundary off Mohammad Abbas.
It took a sturdy knock of 40 from Kevin O'Brien and an even gutsier display from Gary Wilson, batting at No. 9 after suffering a blow to his right elbow during practice before the start of play, to lift Ireland from ignominy and, eventually, to three figures in their first Test innings.
Rankin, the 15th man ever, and the first since Kepler Wessels (Australia and South Africa) 25 years ago, to play Test cricket for two nations after making a lone appearance for England in 2014, had an uncertain Azhar (four) edging to Porterfield at second slip.
Trump berates DHS Secretary Kirstjen Nielsen over border security
Homeland Security's deputy secretary position is vacant, so there would be no immediate replacement if Nielsen were to step down. A Homeland Security spokesperson denied the claims that Nielsen had drafted a resignation letter and was close to resigning .
Former England one-day worldwide Joyce, arguably Ireland´s greatest batsman and at 39 the oldest Test debutant since Australia´s Bryce McGain made his bow aged 36 in 2009, appeared to be a victim of the fact the Decision Review System was not being used in this match because Cricket Ireland had decided they could not afford the cost for a one-off game. Abbas returned to claim his fourth and Shadab finished off the innings but Wilson's unbeaten 33 was symbolic of Irish resolve - a foundation which Joyce and Porterfield built on doughtily during the evening sunshine.
While Rankin took Ireland's first Test wicket, it was not his first in Test cricket.
Veteran opener Ed Joyce was lbw to Mohammad Abbas for four before fellow opener Andrew Balbirnie, who might have been run out for a duck, was lbw to the paceman for nought.
And when he had last man Tim Murtagh caught at short leg, Ireland were 31 runs shy of the follow-on avoidance target of 161.
The hosts picked up two wickets in successive balls in the morning session, to leave Pakistan shocked on 13-2.
With it, Pakistan for the first time in 16 years enforced a follow-on.
Pakistan resumed on their overnight 268 for six.
Imam, the nephew of Pakistan selection chief and former Test batsman Inzamam-ul-Haq, scored a hundred on his one-day worldwide debut against Sri Lanka past year.