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
Dodgers SS Corey Seager looking to leave difficult season in the past
Dodgers shortstop Corey Seager said being sidelined last year while his teammates were making the World Series was difficult, but he spent the offseason undergoing an intense strength-and-agility regimen while recovering from a pair of surgeries.
Phillies still sizing up Bryce Harper, Manny Machado, other free agents
Phillies president Andy MacPhail, who continues to size up free agents such as Bryce Harper and Manny Machado, says "all of our ownership group wants to win."
Roberto Osuna to close for Houston Astros this season
Roberto Osuna will close for the Houston Astros in the right-hander's first full season with the team.
Danny Farquhar takes next step in comeback, throws bullpen session for Yankees
Danny Farquhar, who suffered a brain hemorrhage from a ruptured aneurysm last April, took a massive step toward pitching again the majors, throwing a bullpen session with the Yankees on Friday.
Addison Russell speaks publicly for first time since suspension
Cubs shortstop Addison Russell spoke publicly to reporters Friday for the first time since his suspension for violating Major League Baseball's domestic abuse policies. "I've let a lot of people down," Russell said.
Mets OF Yoenis Cespedes thinks he will play in 2019
Mets OF Yoenis Cespedes says he thinks he will be able to return this season following surgery on both heels last summer, but he doesn't know when he will be ready to play.