Ferrell will play a visiting branch manager over an arc of several episodes. NBC announced the casting Wednesday with the promise that Ferrell's character will be "just as inappropriate" as Steve Carell's Michael Scott.
Carell's farewell is expected four episodes before the season finale of "The Office." In preparation of his exit, NBC is bringing in high-profile guests, including "The Office" creator Ricky Gervais, reprising his role as David Brent.
Gervais will make a cameo in Thursday's episode, which airs at 9 p.m. EST.