López served four stints with Boston in 2006. In 2007, he had three different stints but appeared in 61 games, posting a 3.10 earned run average (ERA). He posted a 15.43 ERA in the playoffs but won his first World Series ring as the Red Sox defeated Colorado in four games. In 2008, he spent the entire season on a major league roster for the first time since 2003. He posted a 9.26 ERA in his first 14 games of 2009 before getting sent to the minors for the rest of the season. In 2010, he signed with the Pittsburgh Pirates but was traded to the San Francisco Giants during the season. He had his lowest ERA that year (2.34) and won another World Series as the Giants defeated the Texas Rangers to win their first World Series since 1954. In 2011, López was one of two major league relief pitchers to throw at least 50 innings without giving up a home run. He won his third World Series in 2012 as the Giants defeated the Detroit Tigers in four games. In 2013, López posted a career-best 1.83 ERA. He won his fourth World Series in 2014 as the Giants defeated the Kansas City Royals in seven games. López announced his retirement on February 8, 2017.