Chasing 378 for victory, England got off to a flying start before the loss of three quick wickets forced them on to the back foot.
Root, batting on 76, combined with Bairstow in a 150-run stand for the unbroken fourth wicket to put England's chase back on track.
England were 259-3 at stumps needing 119 for a series-levelling victory.
England's highest successful run chase came in 2019 when they reached a 359-run target in an Ashes test against Australia on the back of Stokes's brilliant unbeaten century.