From going 0 for 13 with runners in scoring position and leaving a whopping 15 men on base to making two errors in the bottom of the ninth inning, the Colorado Rockies did everything in their power to give the Phillies a ballgame Wednesday night.

And finally, the Phillies took the gift.

The Phillies rallied for four unearned runs with two outs in the ninth inning to beat the Rockies, 6-3.

The Phillies were one out away from falling a season-worst six games under .500 when Chase Utley tied the game with a single against Colorado lefty Boone Logan. The next batter, Ryan Howard, won it with a three-run home run, a bolt into the seats above the 387-foot marker in left-center.

It was Howard’s fifth career walk-off homer.

The Rockies, who had taken a 3-2 lead on a homer by DJ LeMahieu off Jake Diekman in the top of the eighth, left the door open for the Phillies to rally with two errors in the ninth. Second baseman Josh Rutledge threw away a ball with one out and shortstop Troy Tulowitzki dropped a pop up down the left-field line.

The Phillies hardly had a clean game, but performances like the one Mike Adams delivered put them in position to win.

Reliever Antonio Bastardo walked three batters in the seventh and catcher Carlos Ruiz made a throwing error. Adams was summoned into a bases-loaded, no-outs situation and calmly got his team out of the jam unscathed. Without Adams’ clutch work, the Phils probably aren’t in position to rally to win in the ninth.

“Phenomenal,” Howard said of Adams’ work.

Adams induced a 1-2-3 double play off the broken bat of Carlos Gonzalez before striking out Tulowitzki, the league’s leading hitter, on three pitches to end the threat and keep the game tied at 2-2.