The pair, who experienced sharply contrasting fortunes last season, put on 205 in 44 overs after Yorkshire had been struggling on 41 for three with Hampshire opting to field first without a toss.
The partnership came to an end when Lyth was dismissed lbw to Sean Ervine for 111 off 188 balls with 18 fours but Bairstow went on to complete his own century from 167 deliveries coupled with 13 fours and a six.
The England wicketkeeper-batsman was unbeaten on 107 and Yorkshire were 270 for five when bad light ended play for the day.
Lyth lost his England place after failing to impress in last summer’s Ashes series and in his seven Championship appearances he managed only 315 runs with a top score of 67.
But he was back to something near his best in this game in making his first Championship century since his 122 against Nottinghamshire at Trent Bridge in September, 2014.
Bairstow, one of Wisden’s Five Cricketers of the Year, was in the same destructive form that brought him 1,108 Championship runs in nine matches last year at an average of 92.33 to win back his Test place.
The start of the game was delayed half-an-hour while ice melted on the outfield and there was early help with seam and swing for Hampshire’s bowling attack who had much the better of the morning session, although Lyth survived it after Fidel Edwards failed to hold on to a return catch when the batsman was 14.
Alex Lees was taken at third slip by James Vince off James Tomlinson and Gary Ballance soon departed when he was unable to withdraw his bat in time against Chris Wood.
Yorkshire skipper Andrew Gale failed to get off the mark as he brushed a legside delivery from Ryan McLaren into the gloves of Adam Wheater, which left the defending champions reeling at 41 for three.
But Bairstow was soon playing with complete authority, pulling Tomlinson for six and striking a couple of fours as Yorkshire went in to lunch on 80 for three.
Hampshire failed to contain Yorkshire after the interval as McLaren was punished for 41 in four overs. Lyth’s 50 came off 115 balls and Bairstow followed him to the landmark off 63 deliveries.
Batting with increasing confidence, Lyth dashed to his century from 177 balls with 17 boundaries but departed in the first over after tea and in the following over Jack Leaning edged a good ball from Wood to give Wheater his third catch.
Bairstow, partnered by Rashid, mis-hooked a bouncer from Edwards for four to reach his century in an innings in which he rarely seemed in any sort of trouble.
— County Championship (@CountyChamp) April 17, 2016
His progress was halted by bad light and play was called off at six o’clock with 30 overs having been lopped off the day.
England selector, James Whitaker, was at the match and Lyth commented: “It is nice to score runs whoever has come to watch and it cannot do me any harm that he was here.
“I felt good today and I felt good in the Ashes but it just didn’t work out. Hopefully, there will be better things to come. All I can do is score runs and if I get picked again by England that would be fantastic. If not, I will still try and churn out the runs for Yorkshire.”
“After an encouraging performance, Lyth added: “I was very pleased to start the season with three figures. Jonny Bairstow played fantastically and I think we are in a great position now.
“We were in a bit of a tricky position in the morning, so I am very happy with how things have gone. Early season at Headingley is never easy and it was pretty tough but it is great to bat with Jonny because of the way he hits the ball.
“I scored a pre-season century in a match between ourselves and I have felt in good form. My feet have been moving well and I felt that if I could leave the ball well there were runs to be had.