England were 194 for six in their second innings at lunch on the fourth day, still 20 runs shy of making Pakistan bat again as the tourists sought a win that would see them end the four-match series all square at 2-2.
Leg-spinner Shah had rocked England with three for 15 late on Saturday following Younis Khan's commanding 218 in Pakistan's first innings 542.
And he struck again just before lunch when he had first-innings century-maker Ali caught behind for 32. Jonny Bairstow, enjoying a brilliant year with the bat, was 70 not out and Chris Woakes unbeaten on nought.
But Sohail Khan, a right-arm, English-style seamer, made the breakthrough on an overcast morning when his lifting ball had Ballance, carelessly flirting outside off stump, caught behind for 17.
Ali, who had frustrated Pakistan with a first-innings 108, replaced fellow left-hander Ballance and promptly clipped his first ball, a leg-stump half-volley from Sohail, for four.
Ali and wicket-keeper Bairstow had shared a first-innings stand of 93 but England wanted an even bigger partnership from them now. Bairstow completed his second fifty of the match in 72 balls including five fours.
Disclaimer: No Business Standard Journalist was involved in creation of this content
