PITTSBURGH (AP) — Ke’Bryan Hayes singled in the tying run and scored the winning run on an error as the Pittsburgh Pirates scored twice in the bottom of the 10th inning to beat the San Diego Padres 7-6.

Hayes hit a leadoff single into center field off Luis Garcia (0-1) that scored automatic runner Jake Marisnick with the tying run. First baseman Eric Hosmer then misplayed Bryan Reynolds’ ground ball.

The ball rolled down the right-field line and Hayes scored from first base. Hayes was originally called out by home plate umpire Mark Wegner.

However, video replay showed Hayes beat second baseman Jake Cronenworth’s relay throw and the call was overturned.

The Pirates ended their four-game losing streak and snapped the Padres’ four-game winning streak.