Kevin O’Brien batted for over five hours and faced 216 deliveries en route to his historic Test century on Monday.

The record-breaking Irish batsman, alas, was out first ball on the fifth and final day of the Test match at Malahide.

And that ultimately set the tone for the rest of the final day as Ireland came up a little short, as they ended up with a second innings total of 339 with just 20 runs added in the first hour’s play.

And despite an early scare, where Ireland had Pakistan struggling at 14 for three, the tourists secured the win just before tea thanks to two half-centuries from Imam-ul-Haq and Babar Azam.

Anxious and very aware, no doubt, of Ireland’s still precarious position in their quest to secure a positive result from their maiden Test voyage, O’Brien was keen to follow on from his epic performance from Day 4 as he re-entered the fray alongside Tyrone Kane first thing on the final morning.

Mick Jagger had turned up to watch the cricket at the north Dublin venue and O’Brien’s performance proved a cricketing equivalent of the Rolling Stones front man rocking the big arena stages back in his prime, as he worked through all the hits on Monday in Malahide.

But there would be no encore from O’Brien. And no Ruby Tuesday for Ireland.

The morning was but a few minutes old – Kane had faced the first over of the day – when O’Brien decided to go after a very wide Mohammad Abbas out swinger, and thrashed at the ball, looking to smash it through cover.

A thick edge winged its way straight into the grateful hands of Haris Sohail waiting in the slip cordon and Pakistan could hardly believe their great fortune as suddenly they were within touching distance of finishing off this memorable Irish innings.

It was primarily O’Brien’s graft and guile that brought Ireland to this juncture, taking their first ever Test match into the fifth day, but now only two wickets remained with the lead just over 140.

Kane had played a major cameo role in O’Brien’s 118 on Monday but there was little that the young Dubliner could do, alongside Boyd Rankin and then Tim Murtagh, as the Irish innings came to a premature conclusion a long way out from lunch.

"I’m extremely proud of how we went about it. All five days, it was a hell of an effort," said Ireland captain William Porterfield, speaking to RTÉ Sport after the game.

"How the lads acquitted themselves throughout the five days, I cannot fault anyone at all.

"We put ourselves in a position where we knew we were always going to be in with a sniff and [the pitch] was still doing enough to bowl them out.

"An extra 30 or so runs and giving them a target closer to 200 would have made it a very interesting game."

A quick turnaround, as Pakistan came out to knock off the 160 runs needed to secure the victory ahead of their tour of England.

But this Irish team will always attempt to throw a reverse-swinging spanner into the works and sure enough, they gave the visitors a major fright.

Tim Murtagh took the new ball, and four deliveries later, a tentative effort from batsman Azhar Ali resulted in a big edge that was snaffled at first slip by Paul Stirling.

The breakthrough buoyed the bowlers and sure enough, Boyd Rankin needed less than two overs from the Castle End to stamp his size 12s on proceedings as Sohail clipped a low effort to gully, where Ed Joyce was waiting to make an excellent catch.

Five balls later Pakistan were shell-shocked, the scoreboard remarkably reading 14 for three, as Murtagh took his second wicket of the day with the Ireland strike bowler sending an absolute corker down the track and straight through between bat and off stump, as Asad Shafiq was out for a solitary run.

The shock was very much on the cards. A clearly under-pressure Pakistan side still needed 146 runs to win with now just seven wickets in hand.

But of course, it would just take one good partnership to break the back of this Test target and young opener Imam-ul-Haq proved the right man to take back control of the match for Pakistan.

Joined in the middle by number five batsman, Babar Azam, Imam began to settle into his innings and before long, secured his half-century, displaying a fine array of shots to make light work of the Irish bowling.

Azam also pushed past 50 before getting himself run out as captain Sarfraz Ahmed, and then Shadab Khan joined opener Imam in the middle to see the game to the conclusion.

"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.

"They came out and played positively, which was always going to give us a chance, but it was what they had to do to get over the line."

But what a Test debut for Ireland, who at one stage on Sunday looked completely out of their depth as they found themselves on seven for four in their first batting innings.

From there, they dragged themselves back into the match and played their way into contention going into the final day against a Test nation stalwart as Pakistan.

"We had a lot of great support throughout the five days and there were a lot of special moments"

It was not to be, of course, however, Porterfield was taking many positives from the five-day experience, and while Kevin O’Brien was awarded the man of the match for his maiden century and a fine 40 in the first innings, the captain felt that every man on the team contributed to the overall performance.

"The biggest thing is the way we fought back in the second innings and that showed the character that we have. We got a taste of how tough it can be but we also got to prove that we can bounce back in any of those situations.

"We had a lot of great support throughout the five days and there were a lot of special moments.

"I think it was a fantastic team effort, yesterday belonged to Kevin and very well supported by Tommo and TK. But overall, all the lads are delighted and they all played a roll throughout the game, so it is great for ourselves and it gives us a lot of belief.

"But Test cricket is Test cricket for a reason. It’s in the name and you do get tested throughout. And we were in that first innings, but to get to 340 shows the character in that changing room and the passion we have to play for our country."