Australia was 313-8 at stumps after a rain-affected day, in reply to Sri Lanka's 212 all out.
Green's and Carey's rapidfire stand of 84 runs from 93 balls propelled Australia past Sri Lanka's total and further in charge.
Green made 77 off 109 deliveries, including six boundaries, and Carey 45 from 47 after opener Usman Khawaja kept the innings together with 71.
Australia looked set for a bigger lead when it resumed after tea on 233-5 but Carey played a rash shot against offspinner Ramesh Mendis and Dinesh Chandimal took a well-judged high catch running behind from wide mid off.
Green and Mitchell Starc added 37 for the seventh wicket then Green attempted to sweep a full ball from Mendis and was adjudged lbw. He reviewed the umpire's decision unsuccessfully.
Starc was the eighth man out for 10 when he chipped a return catch to legspinner Jeffrey Vandersay.
Captain Pat Cummins hit three sixes and a boundary in a 16-ball unbeaten 26 to ensure Australia took the lead past 100 runs. Nathan Lyon is with Cummins on 8.
Offspinner Ramesh Mendis had the best bowling figures of 4-107 while Vandersay had 2-68 — including Khawaja — for his first wickets in his test debut.
Play commenced on the second day only after the entire morning session and one hour of the middle session were lost because of heavy wind and rain.
Australia, 98-3 overnight, lost nightwatchman Travis Head for 6 quickly when he returned a leading edge to offspinner Dhananjaya de Silva.
Khawaja and Green used their feet against sharp turn and bounce, easily making singles and doubles while rotating the strike. The ploy brought success on a pitch where defense didn't seem a wise option with close catchers around the bat.
They added 57 runs for the fifth wicket when Vandersay got Khawaja caught at square leg by Pathum Nissanka. Khawaja's 17th test half-century came in his 50th match. He faced 130 deliveries and hit seven boundaries.
From 157-5, Green and Carey ended any hope Sri Lanka had of scuttling the Australians quickly.