An unfinished 66-run stand for the eighth wicket between Niroshan Dickwella and Suranga Lakmal stopped the rot. Sri Lanka trail New Zealand by 22 runs.
Niroshan Dickwella, Akila Dananjaya, Lakshan Sandakan and Danushka Gunathilaka have been recalled by Sri Lanka the Bangladesh ODI series.
JP Duminy, who scored 76 runs in the series, has jumped from 39th to 32nd spot.
Mendis, who was also adjudged Player of the Match in Sri Lanka’s win over South Africa in the second Test, is now sitting at 18th spot.
Lakmal said a key for Sri Lanka's bowlers was that they bowled consistently in the right areas.
South Africa had an overall lead of 159 after bowling out the tourists for 154 in their first innings at St George's Park.
Sri Lanka came into the match having lost six of their most recent seven Tests and with several changes in playing personnel.
Sri Lanka have dropped skipper Dinesh Chandimal for their tour of South Africa and have named opener Dimuth Karunaratne as the stand-in skipper.
Niroshan Dickwella's 64 helped get Sri Lanka to a semblance of respectability.
Sri Lanka were huge trouble at the dinner break on the opening day in Brisbane.