Worcestershire 257 and 50 for 2 need a further 393 to beat Somerset 337 and 362 for 9 dec (Azhar 125, Trescothick 71, Moeen 5-107)
Azhar Ali scored a century on his Somerset debut - despite a five-wicket haul from England spinner Moeen Ali - as Worcestershire were set a daunting 443 target in the Specsavers County Championship clash at Blackfinch New Road.
The Pakistan batsman is an overseas replacement in the Championship for injured Australian batsman Matt Renshaw who had scored a hundred on his first appearance for Somerset - coincidentally also against Worcestershire - at the Cooper Associates County Ground in April.
Azhar struck two sixes and 13 fours in his 125 from 188 balls before he was last out at 362 for 9, as Moeen completed his five-for. That left bottom-placed Worcestershire needing to survive 15 overs and they lost Daryl Mitchell and Moeen in reaching 50 for 2 by the close.
They will need a repeat of the rearguard action evident in batting through nearly four sessions in their previous Championship match with Nottinghamshire last month, when they survived nearly 115 overs to earn a draw.
Moeen did his chances of an England Test recall no harm at all in front of selector James Taylor as he returned his first five-wicket haul in the Championship for five years. He finished with 5 for 107 from 33.5 overs and a match analysis of 55.5-9-172-8 ahead of the England selectors choosing the squad for the first Test with India on Thursday.
Moeen extracted some turn and bounce bowling from the Diglis End and another England spinner in Jack Leach could have a key role to play on the final day.
Somerset resumed on 47 for 0 and openers Marcus Trescothick and Ed Byrom extended their partnership to 97 before Moeen came into the attack and struck three times in the space of four overs. Bryrom played back to Moeen and was lbw and in his next over the 31-year-old claimed his 300th first-class wicket as Trescothick took a pace down the wicket and was stumped by debutant Alex Milton.
Trescothick - playing his first Championship match since recovering from a foot injury suffered in May - struck 13 fours in a knock spanning 106 balls.
James Hildreth survived a dropped chance to short leg on 5 off Moeen but it was not a costly miss for the home side as he failed to add to his total before being leg before to the same bowler when caught on the crease. Azhar and Tom Abell 73 for the fourth wicket before the latter on 31 was bowled by Steve Magoffin.
Moeen returned to the attack to account for former Worcestershire team-mate Steven Davies who went back to cut and was lbw. It became 239 for 6 when Peter Trego went for a ugly heave across the line and was bowled by Ed Barnard.
In the penultimate over before tea, Craig Overton was run out by Brett D'Oliveira's direct hit from mid-on after attempting a risky looking single off Moeen.
Azhar was unbeaten on 97 at that juncture and he quickly moved to three figures on the resumption. Jamie Overton holed out to cover off Dillon Pennington and Azhar finally perished attempting a reverse sweep against Moeen with Milton completing the catch.
Moeen's previous five-for in the Championship was his 6 for 77 against Northamptonshire at New Road in the final game of the 2013 season.