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
Athletics' Bob Melvin nabs AL Manager of the Year honors
Oakland Athletics skipper Bob Melvin was named American League Manager of the Year on Tuesday after guiding the team with the lowest opening-day payroll in baseball to a 97-65 record and its first playoff berth in four years.
Brian Snitker is NL's top manager after leading Braves to East title
After leading the Braves to an unexpected NL East title, Brian Snitker has been named the NL manager of the year.
Did Ohtani deserve Rookie of the Year?
Around the Horn discuss whether Shohei Ohtani deserved Rookie of the Year even though he only played 104 games this season.
MLB to investigate claims of racial discrimination vs. Mariners
MLB said in a statement provided to The Athletic that it will investigate allegations of racial discrimination in the Seattle Mariners organization made by a former employee.
Time for Giants to decide what to do with Madison Bumgarner
Forget nostalgia. With Farhan Zaidi taking over the front office, San Francisco must re-evaluate how the hero of Octobers past fits into the franchise's future.
Phillies manager Gabe Kapler loses Malibu home in Woolsey Fire
Phillies manager Gabe Kapler is thankful his family is safe after his Malibu home was destroyed in the Woolsey Fire that has burned at least 435 buildings and is threatening tens of thousands more.