Milwaukee has been without starting second baseman Rickie Weeks after he had season-ending surgery on his wrist in May. Since then, 38-year-old veteran Craig Counsell and rookie Casey McGehee have filled in, but Lopez gives the Brewers a more consistent veteran.
"It's exciting," Lopez said from St. Louis. "It's tough leaving the guys here. At the same time, I'm excited for the opportunity."
The 29-year-old Lopez is hitting .301 with six homers, 25 RBIs and six stolen bases in 85 games in his first season with the Diamondbacks. He can become a free agent after the season.
"Felipe is an accomplished veteran player who gives us versatility at three infield positions," Brewers general manager Doug Melvin said. "He has been a very productive player at the top of the order with respect to both batting average and on-base percentage."
Lopez, a nine-year veteran, is expected to join the Brewers in time for their game at Pittsburgh on Monday.
"I'm leaving here on a good note," said Lopez, who has also played for Toronto, Cincinnati, Washington and St. Louis. "I love this organization. It's one of the reason I signed here to begin with. I believe in this team. This team is only ... pieces away from being really good. It's just the business side."
The Diamondbacks, who fell to 39-53 after Sunday's 2-1 road loss to St. Louis, got outfielder Cole Gillespie and right-hander Roque Mercedes from the Brewers in the deal. Arizona began Sunday 18 games behind Los Angeles in the NL West.
"With our place in the standings, we have to consider trades like this," Diamondbacks general manager Josh Byrnes said. "Felipe will be a free agent at the end of the year, and we acquired a couple of guys with long-term value."
Gillespie hit .242 with seven home runs and 27 RBIs for Triple-A Nashville. Mercedes was 1-1 with six saves and a 1.08 ERA in 29 appearances for Class A Brevard County.
The Diamondbacks are expected to call up Ryan Roberts from Triple-A Reno to take Lopez's place at second base.