The rapid partnership between Karunaratne (42) and Madushka (36) in the last 14 overs of the day left Sri Lanka trailing by 118, but the tourists finished wicketless. They reached stumps in Colombo at a run-rate of 5.71, vindicating new captain Dhananjaya de Silva's pledge to pursue an aggressive strategy.
The tourists were 109-2 after mainstay Rahmat Shah steadied them after a shaky start, but Sri Lanka's bowlers began to make inroads after lunch.
Vishwa found sideways deliveries to trouble the Afghans, who lost their last six wickets for 43 runs -- Asitha clearing the final two in three deliveries. Rahmat, Afghanistan's most experienced player who has featured in all their previous seven Tests, top-scored with an aggressive 91 that featured 13 boundaries.
A terrific one-handed catch from Sadeera Samarawickrama sent Rahmat back after a failed paddle sweep on a ball pitched on off-stump by Jayasuriya.
Vishwa took a good return catch to dismiss opening batsman Noor Ali Zadran for 31, breaking his 57-run stand for the second wicket with Rahmat. Noor was making his debut at the unusual age of 35.
Nisha Madushka at gully took a low catch to dismiss Ikram Alikhil for 21. Opener Ibrahim Zadran fell for a duck in the day's second ball. The match, which is not part of the World Test Championship (WTC), will be followed by three ODIs in Kandy and three T20 matches in Dambulla.
One-of-a-kind Omarzai rallies the Afghan dream
How underrated are Zadran-Gurbaz as an opening pair?
Jayasuriya's dominance and Pakistan's inefficacious spin attack
Sri Lanka with an aim to spring an Indian surprise
Oshada Fernando: Mickey Arthur is open-minded and has had a positive impact on Sri Lanka
How Sanath Jayasuriya influenced the approach of batsmen in ODIs
When India passed a tough test against Afghanistan
Windies clinch first ODI series win in 5 years