Sri Lanka qualified for the CB Series finals with a do-or-die win in the final group game against Australia.
Dan Christian took a hat-trick in a haul of 5-31 as Sri Lanka were bowled out for 238 in exactly 50 overs after opting to bat first in Melbourne.
Australia, chasing under floodlights, recovered from 26-3 thanks to an 87-run stand for the fourth wicket between Shane Watson (65) and Michael Hussey (29).
And David Hussey (74) took it down to the final over but, with 10 needed, he holed out to long-off from Nuwan Kulasekara's first delivery as Sri Lanka prevailed by nine runs.
Australia were already guaranteed a spot in the best-of-three finals but would have faced India - rather than Sri Lanka - in the final had they won.
The two sides now renew their rivalry in Brisbane on March 4, followed by matches in Adelaide on March 6 and 8.
Lasith Malinga - who had already got rid of David Warner (six) and Peter Forrest (two) in a devastating spell with the new ball - was reintroduced into the attack and clean-bowled Watson for 65 to change the shape of the match.
Shortly after, Sachitra Senanayake (1-50) took an excellent catch off his own bowling to dismiss Christian for three and all of a sudden Australia were reduced to 151-6 in the 34th over.
James Pattinson and Clint McKay fell soon after as the required-rate soon rose above a run-a-ball, but David Hussey was the final stumbling block between Sri Lanka and their spot in the finals series.
Hussey kept finding the gaps in the field and was turning singles into twos with some strong support from Xavier Doherty at the other end as the equation was reduced to 23 from the final three overs.
Malinga (4-49) deceived Doherty with a slower ball to make it nine down and it was left to Hussey to score 10 from the final over, but the Victoria batsman could only pick out Tillakaratne Dilshan off the bowling of Kulasekara (2-38) to seal Sri Lanka's progress.
Earlier, Christian picked up the wickets of Thisara Perera (five), Senanayake (nought) and Kulasekara (nought) to gain the first international one-day hat trick at the MCG since Anthony Stuart's effort in 1997 against Pakistan.
Dinesh Chandimal (75) and Kumar Sangakkara (64) had taken Sri Lanka to 140-2 before the wheels started to fall off their innings.
Sangakkara got a top edge on a Pattinson delivery to hole out to Forrest at deep square-leg and the Victorian quick, who finished with figures of 4-51, had the impressive Chandimal on his way shortly after as Sri Lanka fell to 186-4.
Angelo Mathews (five) was Christian's first victim when Doherty held a running catch in the outfield, before the all-rounder's heroics in his next over left the visitors at 206-8.
Christian had luck on his side in picking up the milestone as Kulasekara looked to be harshly given out lbw, given the delivery hit the Sri Lankan batsman outside the line of off-stump and was drifting down leg.
But nonetheless that hat-trick stood as Christian joined Bruce Reid (1986 v New Zealand), Brett Lee (2003 v Kenya) and Stuart as Australians to have taken an ODI hat-trick.
Some late heroics with the bat from Lahiru Thirimanne (51) allowed Sri Lanka to post a competitive total and that proved to be enough after their excellent effort with the ball.