Tournament debutants Afghanistan sensed a shock after reducing Sri Lanka to 2-2 and then 18-3 in Pool A in Dunedin.
But Jayawardene (100) put on 126 with captain Angelo Mathews (44) and although both departed, Sri Lanka held on to win with 10 balls left.
Asghar Stanikzai with 54 was the top scorer in Afghanistan's 232 all out.
The win was Sri Lanka's first of the tournament following their heavy defeat by New Zealand in the opening match, while Afghanistan remain without a point but above England and Scotland - who meet on Monday - on run rate.
Sri Lanka will face Bangladesh and England during the next week.