Ballance’s century in the first innings could not save Yorkshire from following-on as they trailed by 224 after both sides had batted once.
But the former England man’s unbeaten 78 and 150-run partnership with Alex Lees in the second digs handed the visitors a lifeline going into the final day.
Ballance began the day turning his overnight score of 63 into three figures with an unfussy yet occasionally guileful century.
He helped guide the struggling visitors to a more uplifting position following morning stands with Adil Rashid, David Willey and Steven Patterson.
With Rashid he added 60 runs before the spinner drilled Brad Wheal to James Vince at mid-off – the Hampshire captain taking a good catch above his head.
Willey never looked settled despite the flat track, but accompanied Ballance to a 35-run partnership before he was bowled by Liam Dawson.
Ballance eventually brought up his three figures with a tap and go off 190 deliveries – in an innings which had seen him pass 8,500 first-class runs.
But he departed on 100 as Dawson found his edge, with first slip Sean Ervine produced a stunning catch to bring up maximum bowling points.
Reece Topley finally got his first wicket as a Hampshire player, after missing almost the entirety of 2016 with various injuries, when he had Ben Coad caught at first slip to bring the first innings to a close 74 runs adrift of the follow on target.
An innings win was looking on the cards when Yorkshire lost Adam Lyth in just the fourth over, though, as he tickled Gareth Berg behind - give the fast bowler his fifth scalp of the match.
Hampshire then managed to eke out the prized wicket of Joe Root when he was leg before to Kyle Abbott – the England Test captain beginning his season with a pair of single digit scores.
But Lees and Ballance began a severe rebuilding process which saw the duo share centre stage for 47 overs.
Lees was lucky to remain at the crease at tea when he edged Reece Topley behind on 26, but keeper Lewis McManus spilled a chance to his left.
But the pair both scored half centuries, Ballance off 106 balls and Lees off 136, before starting to accelerate as the ball softened.
Lees did depart for 70 with five overs left to bowl as Abbott returned for a sharp burst to find a thin edge behind –to end 150-run stand - but did not overly weaken the away team’s position.