Former “Office” executive producer Dan Sterling has inked a two-year deal at 20th Century Fox TV.

Under the deal, Sterling will join “Last Man on Earth” as showrunner and executive producer for the comedy’s second season, alongside exec producers Will Forte, Chris Miller and Phil Lorde.

He recently developed a multicam comedy pilot with Lord and Miller through their deal at 20th, which landed at CBS with a put pilot commitment after a competitive situation.

“Getting Dan to come to the studio is such a big win for us,” said Jonnie Davis, TCFTV’s president of creative affairs. “It’s bold and original voices like Dan’s which continue to set our company apart from the others, and we’ve had a fantastic time developing with him this past year. He’s also quite possibly ‘Last Man on Earth’s’ biggest fan, so having him set up shop here and run that show has us all over the moon.”

Sterling was an exec producer on the final season of NBC’s “The Office,” a consulting producer on HBO’s “Girls” and showrunner on Comedy Central’s “The Sarah Silverman Program.”

He also wrote the film “The Interview,” starring Seth Rogen and James Franco.

Sterling is repped by UTA and attorney Robert Offer.