Ryan Howard hit a go-ahead, two-run homer in the sixth inning and the Philadelphia Phillies snapped a nine-game losing streak with a 2-1 victory over the Baltimore Orioles on Thursday.

The Phillies, who have the worst record in the majors at 23-45, avoided being swept in four consecutive series. They had lost 19 of 22.

Overall, Philadelphia was outscored 57-18 during its nine-game skid.

Manny Machado hit his third career leadoff homer and second in three games against the Phillies. But he struck out with runners on first and third and one out in the seventh.

Jake Diekman (1-1) pitched a 1-2-3 sixth in relief of Sean O'Sullivan to earn the win in his first game back from a brief stint at Triple-A.

Luis Garcia struck out Machado and Travis Snider to escape a first-and-third, one-out jam in the seventh that followed a throwing error by second baseman Chase Utley. Snider struck out four times swinging and has fanned in five straight at-bats, going back to Wednesday.

Ken Giles tossed a scoreless eighth and Jonathan Papelbon finished for his 13th save in 13 tries.

Howard hit his 12th homer, connecting on a 1-2 pitch from starter Bud Norris (2-5) to put Philadelphia ahead for the first time in its four-game, home-and-home series against Baltimore.

The Orioles outscored the Phillies 29-7 in three wins, including a 19-3 victory at Camden Yards on Tuesday.

Norris allowed two runs and five hits in six innings. O'Sullivan struck out a career-high seven in five innings, allowing one run and four hits.

Copyright: 2015 The Associated Press. All rights reserved. This material may not be published, broadcast, rewritten or redistributed.