Mahmood, 31, has not played for Pakistan since February 2005 against Australia in Sydney and he replaces paceman Shabbir Ahmed, who has returned home with a groin injury after playing in just the Twenty20 international match last week.
Pakistan were crushed by 164 runs in the first one-day international on Sunday after South Africa amassed a huge total of 392 for six.
''Azhar has been performing consistently in domestic matches and is very keen to make a comeback to international cricket.
He has been given a chance,'' Ehsan Malik, media director of the Pakistan Cricket Board, told Reuters.
Pakistan had to send back unfit fast bowlers Shoaib Akhtar and Umar Gul after the second Test last month while Shabbir only joined them last week before he suffered the groin problem.
''Shabbir unfortunately has been advised rest for three weeks and we are not sure if he would be available for the World Cup,'' Malik said.
Malik said the board was trying to obtain a visa for Mahmood and he should fly out by Tuesday. Mahmood was not picked in the reserve list for the one-dayers in South Africa.
Mahmood, who plays for English county side Surrey, said he was delighted to get a recall.
''It has been a long time, but I never gave up hope because I know I am still good enough to contribute to Pakistan cricket,'' he said.
''I will try to do my best in the one-dayers in South Africa and get into contention for the World Cup,'' the all-rounder said.
Mahmood has played 21 tests and 139 one-dayers for his country and has not been named in Pakistan's provisional squad of 30 players for the World Cup.