The elegant left-hander struck a timely 160 not out as Sri Lanka, who were struggling on 43-4 at one stage, stretched their innings to 302-8 on the second day in reply to the home side's 234.
The 21-year-old opener smashed 19 fours and two sixes as Sri Lanka gained a 68-run lead with two wickets still intact. Lasith Malinga was keeping him company on a determined 12 off 64 deliveries at the close on Thursday.
Tharanga, whose highest in two previous Tests was 47 on debut against India in Ahmedabad last year, earlier added 124 crucial runs for the fifth wicket with skipper Mahela Jayawardene (49).
Jayawardene hit seven fours off 105 balls before he was out playing a pull shot to Mushfiqur Rahim at deep mid-wicket, giving part-time leg-spinner Mohammad Ashraful a wicket off his first ball.
The Sri Lankan captain found himself in the middle after a twin strike from paceman Shahadat Hossain had rocked the middle order.
Hossain removed Thilan Samaraweera and Kumar Sangakkara early in the first session as Sri Lanka struggled after resuming on 25-2.
The seamer struck with the last ball of his first over of the day as Samaraweera (20) went for a drive but edged the ball to wicketkeeper Khaled Mashud.
Hossain, who had dismised Malinga Bandara on the first day, picked up another wicket with the first ball of his next over when vice-captain Sangakkara (zero) was given lbw.
Tharanga remained composed even as wickets fell at the other end. After the century stand with Jayawardene, he added 65 for the sixth wicket with Tillakaratne Dilshan (33).
Dilshan was bowled by Mohammad Rafique while Farveez Maharoof (seven) and Dilshara Fernando (five) fell in quick succession to the other left-arm spinner Enamul Haque.