PITTSBURGH (AP) — Rookie Ji-Hwan Bae hit a game-ending three-run homer in the ninth inning, and the Pittsburgh Pirates beat the Houston Astros 7-4 on Tuesday night.

Pittsburgh led 4-2 entering the ninth, but Houston’s Chas McCormick hit a tying one-out, two-run double off closer David Bednar (1-0), who blew his first save opportunity in five chances.

Rodolfo Castro led off the bottom of the ninth against Ryan Pressly (0-2) and pinch-hitter Andrew McCutchen singled before Bae drove a 2-2 changeup 403 feet to right-center for his second career homer and first walk-off hit.

Ji-Man Choi and Jack Suwinski also homered for the Pirates, who have won six of eight. Alex Bregman and Kyle Tucker went deep for the Astros.