Kevin O’Brien produced another memorable international century to leave Ireland’s inaugural Test with Pakistan fascinatingly poised following the hosts’ spirited fourth-day fightback.

Seven years after O’Brien smashed the quickest World Cup ton in a match-winning innings against England, he went into three figures again, making 118 not out as Ireland, who had been made to follow-on, progressed to 319 for seven, a 139-run lead.

With showers possible on Tuesday, not to mention scoreboard pressure, all results still appear possible when it had seemed like a Pakistan victory was a foregone conclusion at the start of Monday’s play.

Irish optimism was in short supply after being dismissed for 130 first time around, but Ed Joyce and William Porterfield had restored some pride in seeing them through to stumps on Sunday.

Resuming on 64 without loss, still 116 in arrears, the sight of Mohammad Amir moving gingerly due to a “chronic knee problem” flaring up would have provided further encouragement, particularly when he did not open the bowling.

As it was, he was not needed at first. Joyce, with 43, was run out by Faheem Ashraf’s direct hit and there was a pair for Andrew Balbirnie, who was once more trapped in front by Mohammad Abbas.

Niall O’Brien and Porterfield could both have been run out but did not make the most of their second lives as Amir produced a brilliant spell.

Two of O’Brien’s stumps were uprooted, and leg nearly came out too, before Amir finally found Porterfield’s outside edge after several near misses, with Sarfraz Ahmed taking a smart catch to send back Ireland’s captain for 32.

Mercifully for Ireland, Amir was eventually taken out of the attack and though Abbas picked up his fifth lbw dismissal of the contest to remove Paul Stirling, the deficit was dwindling.

Overly-cautious field placements and Amir’s sporadic use were helping, and it was no surprise that it took the return of Pakistan’s chief threat to dismiss Gary Wilson, fishing outside off, to give Amir his 100th Test wicket.

Stuart Thompson just about survived becoming victim number 101 but he, along with Kevin O’Brien, took 14 off two Amir overs to bring Ireland within touching distance of moving in front.

They did so via Kevin O’Brien’s edge through the vacant second-slip region for four and the 34-year-old soon became Ireland’s first male Test half-centurion.

O’Brien and Thompson not only negotiated the new-ball spell but profited in it before tea – by which point Ireland’s lead was 32 – and their continued presence began to deflate Pakistan.

Milestones continued to be reached – first a collective 250, then Thompson’s half-century and the three-figure partnership, which were both brought up by with a controlled pull to the fence.

When the alliance did end, on 114, it was only after Shadab Khan found extra turn to bowl Thompson for 53 and provide a much-needed breakthrough for the tourists.

Kevin O’Brien remained, though, and was closing in on a ton, which many in Malahide thought he had brought up with a boundary deemed as leg byes.

The tension was cranked up further when he was on 99 as Sarfraz turned to Amir, yet Kevin O’Brien would not be denied as he reached the century with a clip through point from his 186th ball.

Both he and Tyrone Kane enjoyed the luck of the Irish at the end, with the former nearly playing on to Abbas in the final over, but the pair carried their bats to conclude a remarkable day for the home team.