At lunch, last man Agar was 69 not out, the 19-year-old breaking a 111-year-old record for the highest score by a No 11 batsman on Test debut of 45 not out set by Australia great Warwick Armstrong against England at the Melbourne Cricket Ground in 1902.
Australia, who were in dire straits at 117 for nine, 98 runs behind Ashes-holders England's first innings 215, after losing five wickets for only nine runs.
Agar, primarily a left-arm spinner and a shock selection for this Test after playing just 10 first-class matches for Western Australia, made a brilliant run-a-ball 50, including seven fours and a six.
Hughes, seven not out overnight, did what so many batsmen in this match had failed to do and stayed in to complete a 94-ball 50.
Australia resumed on 140 runs behind England on 75 for four, after an overcast first day where seamer Peter Siddle rocked England with five for 50.