BALTIMORE — Jonathan Cannon pitched into the sixth inning and the White Sox homered three times, snapping their 12-game losing streak with an 8-1 victory over the Baltimore Orioles on Wednesday night.

Nicky Lopez, Andrew Vaughn and Dominic Fletcher went deep for the White Sox, who improved to 32-109 this season. They need to go 11-10 the rest of the way to avoid matching the post-1900 record of 120 losses by the 1962 New York Mets.

This was their third losing streak of at least 12 games this season — no team had ever done that since 1900 — but Lopez led off the game with a homer and the White Sox looked a lot sharper than they did while losing the first two games of this series by a combined 22-3.

Cannon (3-9) allowed a run and five hits in 5 2/3 innings.

“Good offensive game, great pitching,” Chicago interim manager Grady Sizemore said. “It was a fun one.”

Albert Suárez (7-5) permitted six runs and eight hits in 4 1/3 innings for the Orioles, who entered the game with a half-game lead over the New York Yankees atop the AL East.

Gunnar Henderson led off the bottom of the first with a homer that tied the game at 1, but the Orioles didn’t score again.

“We punched out way too many times,” Baltimore manager Brandon Hyde said. “I thought they forced the action offensively way better than we did. So, not a real good night offensively.”

It was the second time this season both teams led off a game with homers, according to Sportradar. The previous instance was last weekend, when the Los Angeles Dodgers’ Shohei Ohtani went deep in the top of the first and Arizona’s Corbin Carroll hit an inside-the-park homer starting the bottom of the inning.

Chicago took the lead for good when Vaughn hit a solo shot in the fourth and Fletcher added a two-run shot later in the inning.

Luis Robert Jr. hit an RBI double and Lenyn Sosa contributed a sacrifice fly in the fifth. Sosa hit an RBI single in the ninth and Fletcher brought home a run on a groundout.