25-1 outsider Many Clouds, who had shown little form going into the race, won by a length and a half, ridden by jockey Leighton Aspell.
Aspell won last year's Grand National too, making him the first jockey since the 1950s to ride back-to-back winners on different horses.
"It feels wonderful, I asked big questions," Aspell said of Many Clouds, moments after his victory.
"Over the fences he was awesome. I was just hoping his batteries would last and they did," he added.
Yet for much of the Grand National -- arguably the world's most famous and certainly the sport's most prestigious jump race -- it looked as if AP McCoy was about to write an ending befitting the career of a man who has dominated jump racing for two decades.
His horse Shutthefrontdoor was in the leading group as it negotiated the likes for Becher's Brooke and The Chair, some of the toughest jumps in racing.
Last week the 40-year-old Ulsterman, who has won an astonishing 4,356 races, announced he would retire if he won the Grand National for the second time in his career.
Shutthefrontdoor was heavily backed by the betting public sensing a storybook conclusion to McCoy's career. UK and Irish betting firms even predicted they would lose as much as $73 million if McCoy won.
He was well placed going into the final straight but just couldn't keep up after Many Clouds cut lose, and finished back in fifth.
Third time winner
But for Trevor Hemmings, the owner of Many Clouds, it was his third victory in the Grand National.
"I always dreamed of winning my first National," a shocked Hemmings told Channel 4.
"Then along comes a second. That's special. And when a third comes along, it's such a wonderful, wonderful feeling."
Hemming went on to praise Aspell's performance.
"This morning talking we talked about the achievers," said Hemmings.
"They are quiet, confident and experienced. He has all of them."
McCoy's fifth placed finish means he will race again at least once more, in two weeks time at Sandown.