The Australians, trailing by 157 runs on the first innings, finished the fourth day at 209 for three wickets for an overall lead of 52.
Hughes was undefeated on 122 with 16 fours and a six, and captain Michael Clarke had scored eight.
Left-arm spinner Rangana Herath grabbed all three Australian wickets to fall to end the day with figures of three for 54.
Herath first trapped Shane Watson lbw for 21, a decision the batsman challenged and lost.
Shaun Marsh fell to a bat-pad catch at short leg for 18 although television replays showed the ball brushing past his pad to fielder Lahiru Thirimanne. Marsh did not challenge the decision but walked off.
Ricky Ponting became Herath's third victim when he failed to get on top of the ball and edged a catch to Mahela Jayawardene at slip for 28.
Earlier, Angelo Mathews scored his maiden test hundred to give Sri Lanka a handy first-innings lead of 157.
Mathews, 85 not out overnight, was stuck nervously in the nineties, losing three partners in quick succession but finally reached his century with a cover-driven four off Peter Siddle.
The 24-year old all-rounder, who had twice been dismissed in the nineties in his 16-test career, jumped into the air to celebrate his century and was warmly applauded by his team mates in the dressing room.
"It was great getting to it after a couple of missed opportunities," said an elated Mathews.
"This was a very patient knock, close to 270 balls. Even though the wicket was flat and hard the Aussies didn't give it easily. We had to be patient and wait for the loose balls.
"You can always say batting in the nineties you get a bit nervous. I hadn't got a hundred yet and I was a bit nervous on this occasion as well."
Australia made early inroads into the Sri Lankan batting on Monday when Siddle breached the defence of debutant Saminda Eranga (12) and trapped Herath (3) leg before.
Chanaka Welegedara (1) was run out after a misunderstanding with Mathews with both batsmen stuck at the non-striker's end.
Siddle, who replaced the injured Ryan Harris for the final test, was Australia's best bowler, finishing with four for 91.
"There is more turn out there now and some reverse swing. If we can start the day well and score a few runs and get a decent lead you never know," said Clarke.
"In my mind this test is certainly isn't over. There is chance that we could lose it if we don't bat well but the other side is there is certainly a possibility if we can get a decent 150-run lead there is still a chance that we can still win this test match.
"Winning the series would be fantastic for all the boys who have worked really hard for a few months leading up to the series and played some really good cricket. I hate to see us not bat well tomorrow and lose this test and draw the series. We worked too hard for that."