Kevin Pietersen hit a swashbuckling and eventful 151 to brighten England's prospects of a series-levelling victory in the second and final test against hosts Sri Lanka on Thursday.
The 31-year-old batsman lit up day three's play with his array of scintillating shots, hitting 16 fours and six sixes as England secured a handy 185-run lead before being bowled out for 460 in their first innings.
Pietersen, whose attempts at playing his switch-hits earned him an warning, joined Ken Barrington with 20 test tons and now has more international centuries (29) than any other English batsman.
Sri Lanka had one over to face and they survived scoring four without loss, all leg byes.
Nightwatchman Dhammika Prasad came out to open with Lahiru Thirumanne and survived a leg before appeal off Jimmy Anderson.
The day belonged to Pietersen and there was drama when he was in the 90s.
Twice he moved into position to play the controversial switch-hit shot and bowler Tillakaratne Dilshan pulled up during his delivery stride on both occasions when he saw the batsman changing his stance.
Pietersen was subsequently warned for the premeditated movement and was told a repetition would mean a five-run penalty, match referee Javagal Srinath said in a statement.
That, however, did not happen and Pietersen was trapped leg before by left-arm spinner Rangana Herath (6-133) who picked up his 10th five wicket haul in a test innings.
"A longer innings would have done us a world of good but it was so hot out there," Pietersen said. "There was no way I could bat until tomorrow. My right hamstring had gone and both my forearms had gone."
Sri Lanka picked up two wickets during the afternoon session with Herath accounting for Jonathan Trott (64) and Prasad removing Ian Bell (18).
Trott, pushing forward, edged the ball to Sri Lanka skipper Mahela Jayawardene at slip to depart after a 137-ball knock that included seven fours.
Bell was dismissed when his hook found Suraj Randiv at mid-wicket, having helped Pietersen in a fourth-wicket stand of 94 off 118 balls.
Left-arm spinner Herath went on to account for Matt Prior (11), Tim Bresnan (five), Graeme Swann (17) and Anderson (two) as England lost their last five wickets for 49 runs.
Sri Lanka's only success of the morning session came when Dilshan ended Alastair Cook's (94) 5-1/2-half hour vigil at the crease, denying the batsman his 20th test century.
The opener failed to get to the pitch of ball and his edge was held by Jayawardene in the lone slip position. The left-hander faced 278 balls in his watchful knock, during which he hit nine fours.
Cook and Trott, who had scored a valiant century in England's loss in the Galle test, added 91 for the second wicket.
Sri Lanka, who lead the two-match series 1-0, used up both their reviews unsuccessfully before they had taken the second new ball.
Sri Lanka coach Graham Ford said Pietersen had been the difference between the teams.
"We had one little half-chance before lunch when he got an inside edge to one of Dilshan's deliveries. Had it gone to hand we might not have been so far behind in the game as we are right now," he said.