Afghanistan's Rahmat Shah narrowly missed his second career Test century as Sri Lanka's spinners fought back after lunch to take control of their one-off match on Friday.
Prabath Jayasuriya picked two wickets including Rahmat's after lunch to leave the tourists 168-5 by tea in Colombo.
Rahmat batted aggressively for his 91, hitting 13 boundaries before falling to an outstanding catch by Sadeera Samarawickrama after an attempted paddle sweep.
Opener Ibrahim Zadran fell for a duck and Rahmat, the mainstay of Afghanistan's Test side, steadied the innings after walking in on the third ball of the match.
Skipper Hashmatullah Shahidi was the first to go after lunch when he attempted to cut a wide delivery off Vishwa Fernando and was caught behind.
Jayasuriya cleaned up Nasir Jamal for a duck in the next over.
Opener Ibrahim was trapped lbw by Asitha Fernando but the 57-run stand between Noor Ali Zadran and Rahmat steadied the innings and parried the determined Sri Lankan seam attack.
Left-arm seamer Vishwa Fernando took a return catch to dismiss Noor, who fumbled an attempt to flick the ball on the leg side.
Noor, making his debut at the age of 35, hit five boundaries in his knock of 31.
The match, which is not part of the World Test Championship (WTC), will be followed by three one-day internationals in Kandy and three Twenty20s in Dambulla.