After looking lethargic most of the game, the Brewers came alive after Cardinals closer Jason Isringhausen recorded two outs on the first two pitches in the ninth.
After Isringhausen (1-4) got the two quick outs, J.J. Hardy singled, pinch hitter Gabe Kapler hit a blooper to right and Isringhausen walked Jason Kendall to set up Weeks.
Weeks took Isringhausen's second pitch to left field to score Hardy and Kapler.
Brian Shouse (3-0) pitched a scoreless ninth and the Brewers handed St. Louis its first three-game losing streak this season.
Cardinals starter Todd Wellemeyer allowed just two unearned runs over six innings, and the Brewers failed to score in the sixth despite having runners on the corners with no outs.
The Brewers, fresh off being swept in Houston and Florida, came in hitting .239 as a team, and general manager Doug Melvin said he planned to meet with the manager Ned Yost and the coaching staff on Monday to address the issues.
But Milwaukee came through in the nick of time after falling behind quickly 3-0 after two innings.
Albert Pujols homered in the first and the Cardinals got two more in the second off Wellemeyer's RBI single and a bases-loaded walk by Brewers starter Manny Parra.