Jedd Gyorko homered and drove in three runs for Milwaukee, and Mark Mathias had two hits and two RBIs. Josh Lindblom (1-0) struck out a career-high seven in five innings.
The Brewers and White Sox split a home-and-home series, with each team winning two games in their opponent's ballpark.
Yelich had been slumping this season, going 3 for 34 in his first eight games. But the 2018 NL MVP made the most of an ugly misplay by left fielder Eloy Jimenez in the fifth.
''It's probably the luckiest home run in baseball history, definitely top three,'' Yelich said. ''I needed that one. It's been an absolute zoo. I've been awful all year. To have some positivity and be able to smile about something was nice, much needed.''
Rookie phenom Luis Robert went 0 for 4 with four strikeouts as the White Sox dropped their second straight game game after winning six in a row. Gio Gonzalez (0-1) was charged with five runs, four earned, and eight hits in 4 1/3 innings.
Jimenez's miscue raised another round of questions over whether the talented White Sox slugger might be better suited for designated hitter in the long run.
''Was it a tough play for him? Yes. Could it have been made? Should it have been made? Possible. Yes. But he did everything he could to corral it,'' White Sox manager Rick Renteria said.
Yelich's one-out drive dropped inside the line and just out of the reach of Jimenez, who misjudged the flight of the ball. Jimenez's momentum carried him into the protective netting. By the time he regained his footing, Yelich was flying around second base and he beat the throw home, tying it at 2.
Renteria tried to deflect attention away from Jimenez's play in the field.
''That's probably not the story of the game,'' Renteria said. ''The story of the game is we were probably shut down a little bit on the offensive side which didn't give us a whole lot moving forward. Would that have helped us a little bit to maybe stifle that inning? Absolutely. But I don't think that's the story of the game. It is part of it, but I am not denying that.''
After Avisail Garcia walked, Gyorko hit a two-run drive on a 3-2 pitch for his first homer of the season. Orlando Arcia tacked on an RBI single against Matt Foster, giving the Brewers a 5-2 lead.
Yelich's drive was the 30th inside-the-park homer in franchise history. He scored three times after he got Wednesday night off for a mental break.
Gonzalez is winless in his last 14 starts. The left-hander struck out three and walked three.
Lindblom, who signed with Milwaukee in free agency, struck out his first five batters. Nomar Mazara then singled for the White Sox, and Leury Garcia hit a drive to right for his third homer.
Lindblom won for the first time since July 4, 2013, and his first as a starter.
''It's definitely special, I think more so from the standpoint that I was just about to make it through the outing without any issues,'' he said.
Milwaukee optioned infielder Ryon Healy and right-hander J.P. Feyereisen to its alternate side in Appleton, Wisconsin.
HOT IN THE BOX
Leury Garcia also doubled home a run in the ninth. He is hitting .440 (11 for 25) with four RBIs in his last seven games for the White Sox.
White Sox: 2B Nick Madrigal was placed on the 10-day injured list with a separated left shoulder. In order to get down to 28 players on the roster, Chicago also optioned Nicky Delmonico to its alternate site in Schaumburg. ... Mazara left in the seventh after getting hit on the left foot by a pitch. X-rays were negative and he is day to day.
Brewers: LHP Eric Lauer is scheduled to make his first career start against the Reds on Friday. Lauer struck out six in 2 2/3 innings against the Cubs on July 26. Lauer is still in the process of being stretched out. ''He had one outing this year, then he got backed up, but he pitched wonderfully in that outing. He's still being built up but he's a starter. He can pitch against anybody,'' manager Craig Counsell said.
White Sox: RHP Dylan Cease (1-1) is scheduled to start against the Indians on Friday night.
Copyright 2020 STATS LLC and Associated Press. Any commercial use or distribution without the express written consent of STATS LLC and Associated Press is strictly prohibited.