Mendis was 157 not out at the break off 211 deliveries and hitting 19 boundaries and a six.
He shared 117 runs for the fifth wicket with Dinesh Chandimal (42) after Sri Lanka had slumped to 86 for four.
Sri Lanka now has a 167-run run lead with five wickets in hand. Dhananjaya de Silva (24) was batting with Mendis. The pair has added 50 runs for the sixth wicket.
Sri Lanka scored 117 in its first innings and Australia made 203.
