The year 2004 marked the start of his work with director/producer Judd Apatow, first on the film Anchorman: The Legend of Ron Burgundy as Brian Fantana with Steve Carell, David Koechner and Will Ferrell, produced by Apatow and again in 2005 in The 40-Year-Old Virgin with Carell and Seth Rogen, directed by Apatow. He subsequently worked with Apatow in 2007's Knocked Up, as frustrated husband Pete, married to Leslie Mann's character. In that film, he co-starred with Jason Segel, Jonah Hill, Seth Rogen, and Jay Baruchel. Rudd appeared as John Lennon in the comedy film Walk Hard: The Dewey Cox Story in 2007 and as the drug-addled surf instructor in Nicholas Stoller's Forgetting Sarah Marshall in 2008 with Jason Segel and Jonah Hill, both of which Apatow produced. Rudd appeared as uncredited cameos in Year One (2009) and Bridesmaids (2011). In 2012, he starred and also co-produced with Apatow on the film Wanderlust with Jennifer Aniston. He starred in the comedy film This Is 40 with Leslie Mann, a spinoff from Knocked Up, which was directed and produced by Apatow. He reprised his role as Brian Fantana in the 2013 sequel Anchorman 2: The Legend Continues.