Left in the game to bat and with his team trailing by two runs, Lyles drew a two-out walk off Pittsburgh Pirates reliever Clay Holmes to load the bases and set the stage for dramatic rally as Milwaukee eked out a 7-6 victory.
"He did a good job standing there," Milwaukee manager Craig Counsell said of Lyles. "That was his job. I just said, `Don't swing."
Lyles said he knew Holmes was struggling to spot his pitches.
"I was going to give him the first strike and then (Counsell) was going to let me know if we were going to continue to take. A couple close pitches in there, but I had the take sign, so I wasn't swinging."
After the walk to Lyles, Erik Kratz tied the game with a two-run single off Holmes (1-3). Orlando Arcia followed with a walk-off single and was mobbed on the field by his teammates as he put an end to the 5-hour, 36-minute contest.
"After he walked the pitcher, I knew the pressure was on (Holmes), it wasn't on me," Arcia said through team translator Carlos Brizuela. "I just looked for a good pitch to put in play."
The Pirates had taken a 6-4 lead in the top of the 15th. Francisco Cervelli's bloop single with two outs drove in the go-ahead run. A second run scored after Brewers second baseman Jonathan Schoop booted the ball as Cervelli's hit fell softly into short right field.
In the Brewers' half of the inning, Jesus Aguilar drew a one-out walk and moved to second on a wild pitch. After Hernan Perez walked, Ryan Braun struck out. Lyles then walked, bringing Kratz to the plate.
Lyles (3-4), the ninth Milwaukee pitcher, got the win.
The Pirates tied the score in the ninth on Starling Marte's two-out, run-scoring single off Jeremy Jeffress, who blew his fifth save of the season on a day when the Brewers sent struggling former All-Star closer Corey Knebel to the minors.
Mike Moustakas's two-out, two-run homer into the second deck in right field extended the lead to 4-0 in the first.
Steven Brault pitched four hitless innings of relief for the Pirates.
The Brewers halted a five-game losing streak to Pittsburgh.
"It's not the way you want to finish, for sure," Pirates manager Clint Hurdle said.
The Brewers demoted ex-closer and 2017 All-Star Knebel to Triple-A Colorado Springs on Friday to work on his mechanics. The right-hander has a 7.24 ERA since the All-Star break that has raised his season ERA to 5.08. In his last seven appearances, Knebel is 0-2 with an 11.37 ERA.
"It's not easy and we don't have a lot of time left to make adjustments," Counsell said. "But we thought the best chance for us to get Corey throwing the ball well again is to give him this break, give him some time to work."
General manager David Stearns declined to comment on reports that the Brewers had claimed Cincinnati Reds pitcher Matt Harvey on revocable waivers but failed to come to terms on a trade. "There are a lot of players being put on waivers. We've certainly claimed some," Stearns said.
Pirates second baseman Kevin Newman got his first major league hit, a double to left in the second.
GOOD TO BAD
Yelich's night started out well. His first-inning homer, his 22nd of the season, set a career single-season best and extended his hitting streak to 10 games. Then it got ugly as he grounded into three double plays and struck out twice while going hitless in his final six at-bats.
Pirates: Reinstated INF/OF Sean Rodriguez (strained left abdominal muscle) from the 10-day disabled list. He pinch-hit in the 11th. ... 2B Josh Harrison (strained left hamstring) didn't start for the fourth consecutive game but entered the game in the ninth. ... SS Jordy Mercer (strained left calf) remained out of the lineup.
Brewers: Reinstated RHP Joakim Soria (right adductor strain) and RHP Zach Davies (rotator cuff inflammation and back stiffness) from the 10-day DL. Optioned Davies to Class-A Wisconsin. ... INF/OF Nick Franklin has begun a rehab assignment with the Rookie Arizona Brewers. Franklin is on the 60-day DL (right quad strain). ... OF Lorenzo Cain remained in the game after being hit in the left shoulder by an Edgar Santana fastball in the seventh.
Pirates: Jameson Taillon (9-9, 3.58 ERA) is 2-4 with a 3.42 ERA in nine career starts against Milwaukee, including 1-1 in three starts this season.
Brewers: Jhoulys Chacin (13-4) will make his team-leading 28th start. He is 0-1 with a 1.53 ERA in three starts against Pittsburgh this season.
More AP baseball: https://apnews.com/tag/MLBbaseball and https://twitter.com/AP-Sports
MLB All-Stars pick up first win over Japan
Yadier Molina and J.T. Realmuto both homered Sunday to lead the MLB All-Stars to a 7-3 win over Japan for their first win of the six-game exhibition series.
NL Central offseason preview: Can the Brewers do it again?
Milwaukee seems due for some regression, the Cubs don't figure to throw money at their problems and the Cardinals might be looking to add some star power.
Nobody's more valuable than Mike Trout, but will he be MVP?
Whether or not the Angels superstar wins his third MVP award, his impact on the game transcends any trophy.
Justin Verlander, Kate Upton announce birth of daughter
Justin Verlander and wife Kate Upton welcomed a daughter, Genevieve Upton Verlander, on Wednesday.
Red Sox broadcaster Jerry Remy says he's cancer-free
Boston Red Sox television analyst Jerry Remy tweeted Friday that he is currently cancer-free after being diagnosed with the disease again in August.
Report: Nats ownership struck down Bryce Harper-to-Astros deal at deadline
The proposed deal would have sent three minor league Astros prospects to the Nationals in exchange for Bryce Harper, The Athletic reported Saturday.