Kamindu completed his first Test century in 126 balls by hitting a four through cover off Rana, but was caught by Liton Das on the next ball off Rana.
After a brilliant innings of 12 fours and a six, captain de Silva soon came to follow on after trying and failing to hook Rana on a short ball.
Khalid gave Sri Lanka an early scare after spoiling the top order, forcing opener Nishan Madushka (2) to be caught by Mehidy Hasan at third slip at the end of the second over.
Dimuth Karunaratne and Kusal Mendis put on 37 runs for the second wicket, before Khalid struck again when Mendis was caught by Zakir Hasan at gully off the fast bowler.