Starting the day on 48 for three in response to UP's 206 at Green Park in the four-day encounter, Mumbai were eight down for 173 before Iyer (75) and Thakur (87) stitched a 97-run ninth-wicket partnership to help the Suryakumar Yadav-led side gain lost ground.
Iyer, who is primarily an off-spinner, and Thakur, Mumbai's pace spearhead, batted with purpose to register their maiden first-class half-centuries respectively.
For UP, the opening bowling duo of Praveen Kumar (3-77) and Amit Mishra (4-63) shared seven wicketes between themselves to hit Mumbai hard but let the advantage slip away after the lower-order resistance.
In the end it was skipper Piyush Chawla, who not only got the dangerous Thakur back in the pavilion but also put an end to UP's misery by picking the last wicket.
Also Read
With only an over possible in UP's second innings, the hosts were 7 for no loss with openers Mukul Dagar and Prasanth Gupta at the crease.
Uttar Pradesh 206 and 7/0 in 1 over (Mukul Dagar 7 not out, Prasanth Gupta 0 not out; Shardul Thakur 0-7)
Mumbai 270 (Shreyas Iyer 75, Shardul Thakur 87; Amit Mishra 4-63, Praveen Kumar 3-77, Piyush CHawla 2-40).