Worley (4-4) allowed three runs and six hits in six-plus innings. Michael Schwimer pitched out of a jam in the seventh, Antonio Bastardo worked the eighth and Jonathan Papelbon finished for his 18th save in 19 tries. Papelbon allowed a solo homer to Michael McKenry in the ninth.
Ruiz hammered an 0-2 pitch to deep left for his career-best 10th homer to give the Phillies an insurance run in the eighth. Ruiz, a career .265 hitter coming into the year, leads the majors with a .361 average after his 10th three-hit game.
Pirates starter Erik Bedard (4-8) gave up four runs and eight hits in six innings. Pittsburgh came in with the best record in the NL since May 25 at 18-10.
The Phillies have won two straight to climb out of last place, and the five-time defending NL East champion could have some help on the way.
Chase Utley was 2 for 5 with a homer in a game for Triple-A Lehigh Valley. The five-time All-Star second baseman could make his season debut on Wednesday. He has missed the first three months because of chronic knee problems.
Meanwhile, former NL MVP Ryan Howard will start a rehab stint at Class A Lakewood on Thursday if all goes well with an examination on his left Achilles in Philadelphia on Wednesday.
Trailing 4-2 in the seventh, the Pirates rallied against Worley. Clint Barmes walked and McKenry singled. Pinch-hitter Drew Sutton followed with an RBI double down the left-field line.
Schwimer entered and retired Jose Tabata on a sharp bouncer to the mound. Neil Walker lofted a fly ball to shallow left and John Mayberry Jr. nailed McKenry trying to score with a perfect one-hop throw to the plate.
The Pirates squandered another opportunity to tie it in the eighth after Andrew McCutchen led off with a double off Bastardo. Josh Harrison, pinch-hitting for cleanup hitter Garrett Jones, popped up a bunt that Ruiz ran down. Casey McGehee popped out and Pedro Alvarez struck out.
Wigginton gave Philadelphia a 4-1 lead in the third when he hit a two-run shot to left-center with two outs.
McGehee's two-out RBI single in the sixth got the Pirates within 4-2. McCutchen doubled and scored on the hit.
The Phillies took a 1-0 lead in the first on an RBI single by Ruiz. Hunter Pence hit a triple off the scoreboard in right-center with two outs. Ruiz then hit a hard grounder to left on an 0-2 pitch.
Alvarez led off the second with a double, advanced to third on a grounder and scored on McKenry's sacrifice fly to tie it. Placido Polanco's two-out RBI single to left put the Phillies ahead 2-1 in the bottom half.
Worley escaped a first-and-second, no-out jam in the first, helping himself with an excellent defensive play. Worley charged off the mound, fielded Jones' slow roller and flipped the ball with his glove to Ruiz to retire Tabata trying to score.
Notes: Phillies C Brian Schneider had an MRI that revealed a high ankle sprain. He'll miss three to five weeks. ... Sutton joined the Pirates earlier in the day after being claimed off waivers from Tampa Bay on Sunday. LHP Doug Slaten was optioned to Triple-A Indianapolis to make room on the roster. The Pirates also called up C Eric Fryer and optioned INF Matt Hague. ... Alvarez is 8 for 18 with four homers and nine RBIs in last three four road games. ... Worley has a 2.70 ERA in five starts since returning from an elbow injury. ... The Phillies have sold out 259 straight games, including postseason. ... James McDonald (6-3, 2.19) starts for the Pirates on Wednesday against an undetermined starter for Philadelphia.