Philadelphia took an 8-3 lead into the bottom of the ninth, but Jacob Diekman walked two and gave up two hits -- one of them a bases-loaded double by Wellington Castillo that allowed Chicago to get within two.
Jonathan Papelbon replaced Diekman and surrendered an RBI single to Darwin Barney before retiring Reed Johnson on a grounder to end the game. Papelbon collected his 11th save and preserved the victory for starter Roy Halladay (4-3).
Halladay threw 99 pitches over eight innings while giving up three runs on seven hits.
Ruiz had an RBI single in both the first and fifth and doubled home a run during Philadelphia's three-run eighth. The Phillies also produced a three-run second, during which Hunter Pence had a two-run single.
Chris Volstad (0-6) made it through just two innings in taking the loss. He was charged with four runs on six hits.