Dhananjaya de Silva and Kusal Mendis struck unbeaten centuries as Sri Lanka reached 404-4 at stumps on day three of the first Test against Pakistan in Rawalpindi on Wednesday, turning a difficult position into one of command.

Resuming on 114-3 in reply to Pakistan’s 434-9 declared, Sri Lanka added 290 runs for the loss of just one wicket during the day. When bad light brought play to an early end, with 23 overs still to be bowled, the visitors were only 30 runs behind Pakistan’s first-innings total, with six wickets in hand.

De Silva led the recovery with an unbeaten 167 from 241 balls, striking 20 fours. It was his 14th Test century, reached off 151 balls, and he went on to pass 150 from 216 deliveries. Mendis, captaining Sri Lanka in a Test for the first time, finished on 117 not out from 188 balls, with 10 fours and four sixes, bringing up his 11th Test hundred off 152 balls with a ramped boundary over the wicketkeeper’s head.

The pair put together an unbroken 249-run partnership for the fifth wicket, Sri Lanka’s highest fifth-wicket stand against Pakistan. They came together with their side in trouble at 155-4 and dominated the final two sessions, moving from 221-4 at lunch to 348-4 at tea before closing in on Pakistan’s total.

De Silva had a moment of fortune early in his innings, when Saud Shakeel dropped him on 38 at slip. From there he was largely untroubled, driving and cutting with authority on a pitch that offered little to Pakistan’s bowlers as the day wore on.

Pakistan’s attack, described by several reports as inexperienced, struggled for a breakthrough. The accurate Mohammad Abbas was the pick of the bowlers with 2-64, but the rest of the attack could not dislodge either batter, and the home side’s frustration grew as the partnership passed 200 and then approached 250.

Earlier in the innings, Kamindu Mendis had contributed 58 and Lahiru Udara 42, but it was the stand between the former and current Test captains that defined the day. Mendis’s century, in his first Test as captain, was a composed innings that steadied Sri Lanka after the early losses and then accelerated as the bowlers tired.

The day’s play was the third of a match that had already produced plenty of incident. Pakistan had declared at 434-9 on day two, and Sri Lanka had struggled to 114-3 by the close, with debutant pace bowler Saqib Khan taking two wickets. The recovery on day three has changed the shape of the match entirely.

With six wickets in hand and the pitch expected to remain good for batting, Sri Lanka will look to move past Pakistan’s total early on day four and build a lead. Pakistan, meanwhile, will need early wickets to stay in the match, and will be regretting the dropped catch that allowed de Silva to go on to his big score.

The second Test of the series, originally scheduled for Lahore, was moved to Rawalpindi because of smog in Lahore, and the first Test will now be decided over the remaining two days, with Sri Lanka firmly in the stronger position.