Kumar Sangakkara top-scored with 112 in a commanding Sri Lanka total of 300 for nine and England struggled in reply until the arrival of Buttler who smashed 121 off 74 balls.
He fell in the final over bowled by Lasith Malinga and the series will be decided in the fifth and final game at Edgbaston on Tuesday.
"That's the best I've ever played," man-of-the match Buttler told reporters. "It's brilliant to play that well but it's disappointing not to get over the line.
"Me and Ravi just had some fun. We didn't think we could win, but that gave us a licence.
"When someone like Malinga comes back at the end, you know it's going to be hard. Kulasekara bowled a really good penultimate over too."
Having skittled Sri Lanka out for 67 in the third ODI on Wednesday, England won the toss and elected to bowl as they strove to wrap up the series.
However, the tourists attacked England early and despite losing opener Kusal Perera for 19, Tillakaratne Dilshan and Sangakkara dominated a limp England bowling attack to add 172 for the second wicket.
Dilshan was bowled by James Anderson for 71 attempting his infamous scoop shot, but Sangakkara continued to dispatch the England bowlers with ease, reaching his 19th ODI century from 95 balls.
Mahela Jayawardene fell for seven and Sangakkara was stumped by Buttler after dancing down the track to spinner James Tredwell.
Sri Lanka lost steady wickets after the dismissal of Sangakkara and Harry Gurney finished with figures of four for 55, but Ajantha Mendis clubbed the last ball of the innings for four to leave England chasing a mammoth total.
England's reply got off to a dismal start when Malinga dismissed captain Alastair Cook (1) and Ian Bell (7) to leave the hosts reeling at 10 for two.
Gary Ballance (42) and Joe Root (43) built a steady partnership before falling in quick succession but Ravi Bopara (51) and Buttler put on 133 to give England a chance.
Buttler was run out in the final over with nine runs required from three balls to send the series into a final-game decider.
"That was one hell of a game," Sri Lanka captain Angelo Mathews said. "Jos batted brilliantly, but we saved the best till last and it's pretty hard to get 10 runs of Lasith Malinga. He is the man for us.
"Sangakkara and Dilshan batted extremely well; they set the platform.
"All in all, 300 was a good score. We know if we get past 250 we have a good chance."
- Sports & Recreation
- Kumar Sangakkara
- Lasith Malinga
- Sri Lanka
- Tillakaratne Dilshan