With the game tied 2-2 and one out in the bottom of the ninth, Casper Wells reached first when shortstop Ramirez committed a throwing error, then advanced to second when Carlos Ruiz singled against Brandon League (6-4).
Young then sent a routine grounder to Ramirez, who bobbled it, allowing Wells to cross the plate for the game-winner.
Ruiz went 4-for-4 and Darin Ruf smacked a solo homer as new Phillies Manager Ryne Sandberg logged his first victory and Philadelphia avoided a three-game sweep.
Jonathan Papelbon (3-1) was credited with the win after tossing a scoreless top of the ninth.
Andre Ethier went 2-for-4 with a solo homer for the National League West-leading Dodgers, who lost for just the second time in August.