Kumar Sangakkara's 34th Test hundred ensured Sri Lanka made good progress after opting to bat first in the second Test against Bangladesh in Chittagong.
Sri Lanka reached 314-5 by the close with Sangakkara unbeaten on 160, an innings that moves him level with Sunil Gavaskar and Brian Lara for fifth on the all-time list of Test century makers.
Bangladesh struck twice in the morning session; Kaushal Silva was lbw for 11 attempting to sweep a quicker delivery from spinner Sohag Gazi and Silva's opening partner Dimuth Karunaratne (31) cut straight to point off seamer Al-Amin Hossain's bowling.
But the home side were made to toil well into the evening session for their next success as veteran third-wicket pair Sangakkara and Mahela Jayawardene put on 178.
Sangakkara was the main aggressor as, from 71-2 at lunch, Sri Lanka cut loose with 125 runs in the afternoon session.
Jayawardene, who made 203 not out in last week's first Test, struck six fours in his 72 but was denied a century - which would also have been his 34th in Tests - when off-spinner Mahmudullah pinned him lbw as he looked to play into the leg side.
There was no stopping Sangakkara. The left-hander brought up his sixth century against Bangladesh - the most by any batsman - from 146 balls and pressed on beyond 150 in the final hour.
Chandimal contributed 27 to a 67-run, fourth-wicket partnership but was caught by Imrul Kayes at point after miscuing an attempt to launch a flighted delivery out of the ground and Mathews (5) was soon bowled by the same man having a big slog.
Kithuruwan Vithanage (0no) survived through to stumps alongside Sangakkara, who has so far faced 245 balls and hit 17 fours and three sixes.
Sri Lanka need only a draw to secure victory in the two-match series having won the first Test by an innings and 248 runs.