Villanueva was signed by the San Francisco Giants in. He and Glenn Woolard were traded to the Milwaukee Brewers on March 30, 2004, for pitchers Wayne Franklin and Leo Estrella. He joined the Beloit Snappers, the Brewers Single A club. As he worked his way through the Brewers' farm system, Villanueva was called up to the Brewers from Double-A Huntsville on May 22,. He made his Major League debut against the Cincinnati Reds on May 23, 2006, pitching a scoreless inning. After being optioned back to the minors, Villanueva was recalled again, making his first career Major League start for the Brewers against the Cincinnati Reds. After a successful 2006 campaign, Villanueva entered the spring training in competition for the Brewers fifth spot in the starting rotation. Despite pitching well, he lost the job to Claudio Vargas. Instead, manager Ned Yost elected to put Villanueva into the bullpen as a middle relief pitcher. Villanueva pitched well in his new role and was occasionally used as a long relief pitcher when Elmer Dessens was placed on the DL. On July 2, Villanueva was 6-0 with a 2.64 ERA. Despite his record, Villanueva was accustomed to only being used as a starting pitcher, and had never appeared in more than 25 games in his professional career. Through July and August, he posted a 1-3 record with an ERA of over 9, perhaps a sign of being overworked. Despite his struggles, he was still being used as a middle relief pitcher. On August 20, after pitching 3 perfect innings against the Arizona Diamondbacks and picking up his first career save, he was optioned to the Triple-A Nashville Sounds to make two starts to "polish up" for a September call up when the rosters expand. Villanueva spent a short part of the season as the closer while Trevor Hoffman recovered on the disabled list; however, after poor performances, the role was given to Todd Coffey instead.
Toronto Blue Jays
On December 3, 2010, Villanueva was traded to the Toronto Blue Jays for a player to be named later. After starting the season in the bullpen for the Blue Jays, he was moved to a position in the starting rotation to fill in for open spots previously filled by Brett Cecil and Jesse Litsch. On August 4, 2011, Villanueva was placed on the 15-day disabled list with a right forearm strain. Villanueva was re-activated from the disabled list on August 31. Brian Tallet was designated for assignment to make room for Villanueva. Villanueva began the 2012 season as the long reliever in the Jays' bullpen, but was promoted to a starter after numerous injuries to the pitching staff. After posting a 6-1 record, Villanueva left the team for personal reasons on August 5. J. A. Happ started in place of Villanueva.
On December 19, 2012, it was reported that Villanueva had agreed a two-year, $10 million contract with the Chicago Cubs. The deal became official on January 26, 2013, more than a month after it was initially agreed upon. Lendy Castillo was designated for assignment to make room for Villanueva on the 40-man roster. Dale Sveum made Villanueva the Cubs fifth starter in their rotation. His first game on April 6, a road game against the Atlanta Braves, resulted in a no decision.
St. Louis Cardinals
On February 4, 2015, the St. Louis Cardinals signed Villanueva to a minor league contract that included an invitation to spring training. The Cardinals added him to their 40-man roster on March 30. On June 27, he pitched the last three innings of an 8–1 victory over the Cubs for his first save of the season, and did so again on August 7 against the Brewers in a 6–0 win. It was his fourth and fifth career save of at least three innings. Villanueva pitched solely out of the bullpen in 2015 and was credited with a 4–3 record with two saves, 55 strikeouts, and 50 hits and 21 walks allowed. He posted career-bests in ERA and inherited runners strand rate ; the WHIP, batting average on balls in play and batting average against were his best figures since his first MLB season with the Brewers.
San Diego Padres
On January 13, 2016, the San Diego Padres signed Villanueva to a one-year, $1.5 million contract.