He made the announcement on the eve of the Karachi Test, saying: "It has been a great honour and privilege for me to represent my country at the highest level. Deciding on when to call it a day is always tough, but, after contemplating deeply, I realised that this is the right time for me to retire from Test cricket.
"There are many people who I am grateful to in this strenuous, yet beautiful journey. I want to make a special mention of my family without whose sacrifices; I would not have been where I am today. My parents, wife, siblings, and children have been my strength throughout.
"I have been blessed to share dressing room with some of the most outstanding cricketers with whom I share a strong bond. I feel much richer by calling these people my friends. I am also blessed to have played under some wonderful coaches to whom I will always remain grateful.
"I retire from international cricket as a fulfilled cricketer who ticked most of the goals he had set for himself. Not many cricketers go on to lead their countries, and that I was able to captain Pakistan is a matter of great pride for me. From being a kid who started as a legspinner to becoming a mainstay in the Test batting line-up, I had the loveliest moments of my life that I will cherish forever."
Azhar, 37, had sat out the previous Test against England, in Multan. He captained Pakistan in nine Tests overall, being appointed full-time captain after Sarfaraz Ahmed was sacked in 2019. Pakistan won two home series under him, against Sri Lanka and Bangladesh, but a slump in personal form and growing criticism of his methods meant Babar Azam took over less than a year later. He had also overseen Pakistan in ODIs from 2015 - taking over after the World Cup, from Misbah-ul-Haq - to 2017, a tumultuous period in the format for them, when they slipped to No. 9 in the ODI rankings.
"Everything has an end just like it has a beginning. My heart and head told me this was the right time. It's been an honour for me to represent Pakistan. Great memories. I'd like to thank all my coaches and colleagues. I haven't seen a better bunch of players."
The writing appeared to be on the wall after a disapppointing showing on a flat surface in Rawalpindi. Azhar managed 67 runs across both innings and was the only member of the top three from either side not to score a hundred. Following that, he was dropped from the second Test in Multan, which ended his chances of completing 100 Tests this home season. Azhar said he had made the decision by himself, though.
"It's my own decision. Nobody coerced me into it. I'm very happy with the way youngsters are coming through. This was going to be my last season anyway. I wanted to play 100 Tests, and if I'd played every Test this season, that would have happened. That won't happen, so it's better to make way for youngsters. I'd also like to consider my own well being and the life I have ahead of me. It was my own decision, not someone else's.
"I'd like to thank my parents. My dad, who believed in me more than I did. And my mother, who's no longer around. Her sacrifices meant the world to me. I miss her."
Azhar ends his career as one of Pakistan's most accomplished Test batters. He is the fifth highest runscorer in the format for Pakistan with 7097 runs with 19 hundreds. His unbeaten 302 against the West Indies in Dubai makes him one of just four Pakistan cricketers to have scored a triple century, and the only cricketer to have scored one in day-night cricket. Among Pakistanis, only Younis Khan, Javed Miandad, Inzamam-ul-Haq and Mohammad Yousaf have scored more Test runs. He also played 53 ODIs, scoring 1845 runs at 36.90, including three hundreds.
Azhar Ali made his debut in 2010 against Australia in the wake of the 2009 terror attack on Sri Lanka in Lahore that forced Pakistan to play international hime matches outside the country. He soon established himself as a mainstay in the Pakistan side, making the number three position his own for several years. In the second half of his career, Pakistan's opening struggles meant he was deployed in that position, too, scoring 1556 runs at 45.76 in 37 innings in that position.
But it wasn't until 2019, nearly a decade after he made his international bow, that he played an international match in Pakistan. It finally came in 2019 against Sri Lanka, and in just his second Test at home proper, he scored 118. A dip in form soon after followed, though there remained flashes of the trademark grit that saw him squeeze so much out of his abilities. There was an unbeaten 141 in Southampton, 93 in Christchurch, as well as 185 at home against Australia in Rawalpindi.
"It was massive to play at home," he said. "I genuinely thought a few years back that I would not be able to play a Test at home because of the duration of the game and no one would come to play just one Test to give us home Test but credit to Pakistan Cricket Board and government to making that happen and making other teams believe that it was safe to play in Pakistan. To score a hundred on home ground was massive."
He played his last ODI for Pakistan in January 2018, and has not played a T20I.