The Brewers overcame a four-run deficit while snapping the Phillies' five-game winning streak.
Segura came through with an RBI triple in the seventh and scored on a throwing error to bring about a 4-4 tie.
He then reached on an infield single with one away in the ninth, moved to third on Ryan Braun's base hit and dashed home with the winning run on the single to left by Ramirez.
Francisco Rodriguez (1-0), the sixth pitcher of the game for the Brewers, worked the top of the ninth to get the victory.
The ninth-inning run was charged to Jeremy Horst (0-2).
Erik Kratz hit a two-run homer for Philadelphia in the fourth to give the Phillies a 4-0 advantage.