The 6-foot-9 Ilyasova spent each of his first seven seasons in the NBA with the Bucks, who made him a second-round pick in 2005.
He has averaged 10.7 points and 6.0 rebounds in his career, and has shot the ball especially well from 3-point range, ranking second in the league in 2011-12 (45.5 percent) and fourth in 2012-13 (44.4).
The move frees up cap space for the Bucks, as Ilyasova was due $7.9 million this season and next, and was due $8.4 million in 2016-17.
"Ersan Ilyasova is a player we have coveted since we got to Detroit," said Pistons coach and president of basketball operations Stan Van Gundy. "Not only is he a proficient 3-point shooter that can stretch the floor, he is a high-energy, hard-playing guy who fits extremely well with how we want to play. We are excited about what he can add to our team."
Ilyasova, of Turkey, also played professionally in Spain for two seasons after the Bucks drafted him.
Butler, a 13-year veteran, averaged 5.9 points, 2.5 rebounds and 1.0 assists in 78 games last season for the Pistons. Williams was claimed by the Pistons off waivers in February. He averaged 2.6 points, 1.4 rebounds and 8.6 minutes in 19 games with Detroit.
Pistons acquire Ilyasova from Bucks
ESPN NBA Insider Bradford Doolittle breaks down the Pistons' acquiring Ersan Ilyasova from the Bucks and what it means for Greg Monroe's future.