Buttler made career-best 150 in 77 balls, blazing his last hundred runs in just 31 deliveries as England posted what looked like a mountainous total of 418-6. But Gayle set up a tense finale by smashing 162 before England held on to take a 2-1 series lead.
1st ODI: Jason Roy and Joe Root send out World Cup warning as England chase a record 360 against West Indies
Chris Gayle boost helps West Indies to break the world record for number of sixes in an innings against England
2nd ODI: West Indies ride Hetmyer's century and Cottrell's five-for to level series 1-1 against England
A total of 46 sixes were hit during the match - a new world record for any ODI. This included 24 from England which also helped them go past their opponents' record of 23 that was created in the 1st game of this series.
"I think it just shows there are going to be unbelievable days of cricket and when someone like Chris Gayle's in the opposition you can lose those games," Buttler said. "We were put under great pressure and I thought the guys did well to stand up to it."
A late salvo from Carlos Brathwaite and Ashley Nurse left the hosts needing 32 from 18 balls to make the second largest chase in ODI history but Adil Rashid wiped out the last four wickets in the 48th over to bowl them out for 389.
Despite the leg-spinner's late intervention, Gayle and Buttler were the day's headline acts, hitting 26 sixes and 24 boundaries between them in a furious display of power-hitting.
England ultimately had the stronger supporting cast, as Eoin Morgan made a 103 of his own during a 204-run stand with Buttler.
England's innings was the highest ever on Caribbean soil and sits third on their all-time list, thanks in part to 154 runs from the final 10 overs.
Buttler and Morgan came together at 165-3, with Joe Root having fallen cheaply, and heaped on another 204 runs together in less than 21 overs.
Gayle is one of a handful of players who would not shirk from chasing 419 and the 39-year-old Jamaican picked up Buttler's baton with a ton of his own.
He teed off immediately, clattering Chris Woakes for five sixes in nine balls.
Stokes then gave up two fours and two sixes from his first four balls. Things did not get any better in a ragged four-over spell that contained full tosses, wides and even an accidental beamer.
But Gayle ticked off a shopping list of targets — 50 up in 32 balls, a 10,000th one-day run and then his hundred in 55 balls — but was fatigued by the time Stokes took his stumps on 162.
The final equation left the West Indies seeking 95 from the last 10 overs, with Brathwaite and Nurse surpassing low expectations in a boundary-strewn cameo that threatened to add one final twist to a day full of entertainment.
They were on the cusp of something special when Rashid kept his composure, tempting both into mis-hits that were held by Morgan and Liam Plunkett. He polished off Devendra Bishoo and Oshane Thomas in a hurry, providing a swift end to a superb battle.