Sri Lanka, seeking a series-levelling win, closed the third day's play at the Sinhalese Sports Club on 428-6 in their first innings, a lead of 112 runs over Australia's 316 with four wickets in hand.
Dilshan struck a rousing 83, Kumar Sangakkara made 79 in his 100th Test appearance, Mahela Jayawardene hit 51 and Angelo Mathews returned unbeaten on 85 as Sri Lanka led Australia for the first time in the series.
Prasanna Jayawardene chipped in with 47, sharing a sixth-wicket stand of 81 with Mathews that increased Australia's frustration in the field on a hot, humid day.
Dilshan, who had contributed just 56 runs in the previous four innings of the series, hammered 14 boundaries before he was caught behind off Trent Copeland just before tea.
Dilshan put on a valuable 121 for the fifth wicket with Mathews on either side of lunch after Australia had threatened to take charge in the morning session.
The tourists grabbed the crucial wickets of Sangakkara and Mahela Jayawardene in the spa