The visitors were 13 without loss at stumps on the penultimate day chasing 382 to win. Simon Katich (eight) and Matthew Hayden (five) were at the crease.
India were tottering at 166-6 in their second innings at the tea-break before posting 295 in their second, thanks to skipper Dhoni (55) and lower-order batsman Harbhajan (52).
Dhoni and Harbhajan kept the Australian attack at bay with their responsible knocks after their team had lost six wickets for just 50 runs in a dramatic afternoon collapse.
India lead 1-0 in the series following their 320-run victory in the second Test in Mohali. The matches in Bangalore and New Delhi were drawn.
Debutant off-spinner Jason Krejza (4-143) grabbed two wickets off successive balls and seamer Shane Watson (4-42) two scalps in three overs to boost Australia's hopes of squaring the series.
Krejza, 25, took 12 wickets in the match. Australia's Bob Massey and India's Narendra Hirwani are the only bowlers to have bagged more than 12 wickets in a debut Test.
But Dhoni and Harbhajan counter-attacked to rally their team. Dhoni hit four boundaries in his 12th Test half-century and Harbhajan struck five fours in his sixth fifty.
Australia skipper Ricky Ponting considerably eased the pressure when he pressed part-time slow bowlers Michael Hussey and Michael Clarke into the attack in the last session, apparently to make up for a slow over-rate.
Under the International Cricket Council regulations, a captain can face ban for his team's slow over-rate.
When Dhoni was caught by a diving Hussey at silly-point off Krejza after scoring a second successive half-century, his team was virtually safe -- 360 runs ahead with three wickets in hand.
India threatened to bat Australia out of the match with a 116-run stand for the opening wicket between an aggressive Virender Sehwag (92) and debutant Murali Vijay (41) before Krejza and Watson struck.
Watson began the slide when he trapped Vijay leg-before and then had out-of-form Rahul Dravid (three) caught behind.
Dravid finished the series with just 120 runs at an average of 17.14.
Paceman Brett Lee, on a drip for dehydration on Saturday afternoon, bowled his heart out on an easy-paced pitch in his five-over second spell and got the prize wicket of Sehwag.
The Indian opener looked set to complete his 16th century in 64 Tests before edging a lifting delivery to wicket-keeper Brad Haddin, who dived to his left to bring off a low catch. He hit one six and 10 fours.
Krejza, who became only the sixth bowler to take eight wickets in a debut innings on Friday, came back strongly to dismiss in-form Venkatsai Laxman and Sourav Ganguly with successive deliveries.
He bowled Laxman (four) with a gem of a delivery that turned sharply from outside the off-stump to knock back the leg.
Ganguly, clapped by the Australians when he walked in for his last Test innings, fell for a first-ball duck when he offered a return catch to diving Krejza.