Australia prevented a world-record, 490-run chase by Pakistan on Friday to win a gripping first Test by just 39 runs and preserve their 28-year unbeaten streak at Brisbane's Gabba ground.
Relieved skipper Steve Smith ran out Yasir Shah for 33 to take the last wicket and end Pakistan's brave attempt to reel in the mammoth target on the last day of the day-night Test.
"I think I lost all my fingernails. Some game of cricket, wasn't it?" said Smith.
"A lot of credit has got to go to the way they played. But I thought our bowlers stuck at it all day, we bowled a lot of overs, our quicks just kept coming back."
The highest ever successful Test run chase of 418 for seven was set by the West Indies against Australia in Antigua in 2003.
And Pakistan looked on course to beat that on the back of Asad Shafiq's knock of 137, but he was caught shortly before Yasir's run out.
His magnificent innings came to end when a Mitchell Starc lifter came off the shoulder of his bat and lobbed to David Warner in the gully for the crucial catch.
Man-of-the-match Shafiq faced 207 balls in 336 minutes and hit 13 fours and a six. While he was at the wicket, Pakistan's hopes of a remarkable victory were still realistic.
"There is energy, we have to go for the match here, so that's what I was aiming for, for the match," said Shafiq.
In the process, Pakistan posted their highest fourth innings total, surpassing their previous best of 382 for three to beat Sri Lanka in Pallekele last year.
"I'm happy, because after the first innings, it was looking very difficult for us to come back in this game," said Pakistan captain Misbah-ul-Haq.
"But the way all the team, all the batsmen showed their character, that was wonderful, and we got some special knocks from the tailenders as well.
"A lot of positives, I'm happy and proud the way the team played in the fourth innings."
The victory, in the first day-night Test at the Gabba, extended Australia's unbeaten record to 28 Tests at the venue since their last defeat in 1988.
It was also Australia's second straight win after Test series defeats to Sri Lanka and South Africa this year prompted a team shake-up.
Australia have now won all three of the pink-ball Tests they have played at home over the last 12 months.
But for much of Monday's final session the Australians were frustrated by Pakistan's tailenders chipping away at their lead.
Shafiq and Yasir were finding runs easy to score. Nathan Lyon made a fantastic flying two-handed effort at point, but narrowly missed catching Yasir on 27.
There was a big moment when Yasir was hit on the back leg while shouldering arms to Josh Hazlewood and given out on 30, but a review showed the ball clearing the stumps and the decision was reversed.
But Starc's brutish delivery to Shafiq grabbed the vital breakthrough, before Smith's throw-down to catch Yasir out of his ground and snatch victory.
Pakistan, despite coming up short, showed by their spirited response that they can do better in the rest of the three-Test series, with Melbourne next up on Boxing Day.
Smith chose not to enforce the follow-on after Pakistan were dismissed for 142, even though they were 287 runs in front on the first innings.
The Australians added a brisk 202 for five batting again and in the end it just proved enough to get the home side over the line