St. Louis fought back from a two-run deficit to tie the game in the seventh, took the lead with two runs in the ninth and then squandered the advantage in the bottom half of the inning.
The Cardinals then produced a run in the 10th off Michael Blazek (0-1), the seventh pitcher of the contest for the Brewers.
St. Louis moved two games in front of both Cincinnati and Pittsburgh in the race for the National League Central title. Cincinnati put together a stunning rally against Pittsburgh earlier in the evening to pull out a 6-5 win.
Kolten Wong began the 10th inning by drawing an 11-pitch walk from Blazek and Matt Carpenter followed with a double that put Wong on third.
That brought up Beltran, who on a 2-0 pitch lifted a fly ball to right that brought home Wong.
Carlos Martinez was called on in the bottom of the 10th and the St. Louis rookie picked up the first save of his career.
Matt Adams put St. Louis ahead with a two-run homer in the ninth, but closer Edward Mujica blew the save chance in the bottom half of the inning when Logan Schafer and Aramis Ramirez both delivered an RBI single.
John Axford (7-7) had to finish the ninth in place of Mujica and wound up getting the win.
Celebrity Families of 2014 [PHOTOS]