Pakistan threw away the chance to take the one-day series opener against South Africa, a late batting collapse seeing them go down by one run in Sharjah.
Having bowled out their opponents for 182, Pakistan looked to be coasting to victory when they reached 165-4 in the 41st over of their reply.
However, the departures of Umar Amin and Umar Akmal in successive deliveries proved a double blow that the 'home' team simply couldn't recover from. They lost 5-12 to leave themselves nine down and still seven short.
The last-wicket pair of Saeed Ajmal and Mohammad Irfan nudged them to the brink before the latter was bowled by Morne Morkel for two, meaning Pakistan had been dismissed narrowly shy of their target and with 21 balls to spare.
Despite losing Nasir Jamshed for a duck, Ahmed Shahzad's 58 and useful contributions from Mohammad Hafeez (28) and skipper Misbah-ul-Haq (31) seemed to be putting Pakistan on course.
Amin (20) and Akmal, who made 18 before being trapped leg before, continued the top-order's good work, only for Imran Tahir to then turn the momentum in South Africa's favour with three wickets in the space of two overs.
The leg-spinner finished up with 3-45, including dismissing the dangerous Shahid Afridi for nine, while seamer Wayne Parnell also claimed three wickets having earlier recorded a maiden half-century with the bat.
The left-hander managed a new ODI best of 56, hitting a six and six fours in a crucial knock that included a 52-run stand for the ninth wicket with Lonwabo Tsotsobe (16 not out).
The Proteas had at one stage found themselves toiling at 86-6 once the spin duo Saeed Ajmal (4-30) and Afridi (3-37) had decimated their batting line-up.
Parnell came out at number eight and helped add 39 with David Miller, who made 37. Afridi eventually broke the alliance and then sent back Morkel four balls later, leaving the South Africans eight down in the 35th over.
Still, the lower order continued the rally, Parnell lasting until the 49th over when he was caught in the deep to become spinner Ajmal's fourth wicket of the match and his 150th in one-day action for his country.
The two teams go on to meet in the second of five matches in the series in Dubai on Friday.