Butler helps Eng draw level
Buttler guided England, chasing 228 for victory, home with three balls to spare after hitting 65 including a six off Mitchell Johnson in the final over.
The five-match series is tied at 1-1 after the first and third games were washed out by rain.
England were reeling at eight for three after fast bowler McKay dismissed Kevin Pietersen, Jonathan Trott and Joe Root in the third over.
Pietersen was trapped lbw for five, Trott edged a catch to Aaron Finch at second slip and Root nicked a full-length delivery to Shane Watson at first slip as McKay became only the fifth Australian to take a hat-trick in one-day internationals.
England recovered with opener Michael Carberry and captain Eoin Morgan sharing a stand of 104.
Morgan was bowled for 53 and when Carberry, who had progressed to 63, his maiden ODI half-century, became debutant Nathan Coulter-Nile’s first ODI victim, England still had work to do.
Ravi Bopara fell cheaply, allowing Ben Stokes (25) to join Buttler and the pair added 75 to take the hosts to the brink of victory.
Australia’s 227 all out owed much to George Bailey’s fluent 87 off 91 balls.