Greg Berlanti is staying put at Warner Bros. Television.

The prolific producer has inked a four-year contract extension that will keep him at the indie studio through 2024.

Sources tell The Hollywood Reporter that Berlanti's new deal is worth $400 million in all-cash guarantees. Berlanti — who has 14 scripted series on the air, a TV record — had two years remaining on his current pact and, with multiple outlets pursuing the writer-producer, opted to remain at his longtime home at Warners. By the time the deal ends in 2024, Berlanti will be 51.

The deal is for only TV, with Berlanti's film pact remaining at Fox, for whom he directed Love, Simon this year. Sources note that Warner Bros. Entertainment CEO Kevin Tsujihara and WBTV president Peter Roth aggressively pursued Berlanti for a new deal. Berlanti, who values loyalty, is said to have been happy at the studio and did not take meetings with any other outlet despite interest from Netflix, among others.

The structure of Berlanti's deal is different from the nine-figure paydays that Shonda Rhimes and Ryan Murphy inked at Netflix. The Arrow, Flash, Riverdale and Supergirl executive producer took a cash payout for the pact, meaning he no longer will receive points on the backend of his series. The new pact is also said to have incentives for Berlanti to become even more prolific than his current 14 shows, with additional cash clauses kicking in when he hits a specific number of series.

By comparison, Murphy's (American Crime Story, 911) $300 million pact is an all-services deal at Netflix that includes TV and film, with the streaming giant also buying out the backend of multiple shows from the showrunner's longtime home at 20th Century Fox Television. Rhimes' (Grey's Anatomy, Scandal) $100 million Netflix deal is structured in a way where she bet on herself and will earn additional fees based on the performance of the projects she creates for the streamer.

"This is a whopper payday," one source close to the deal told THR of the pact, which is described as the "biggest writer-producer deal in the history of TV." Other sources with knowledge of the deal for Warners-based Chuck Lorre say the Big Bang Theory co-creator's contract is worth more than Berlanti's when factoring in lucrative backend points and syndication deals on monster hits such as Big Bang and Two and a Half Men, among other shows, while Berlanti — as prolific as he is — does not have a ratings hit comparable to Lorre's comedies.

All told, Berlanti has 14 live-action scripted series across six networks and produces two animated series airing on a seventh. Berlanti will continue to executive produce The CW's All American, Arrow, Black Lightning, Legends of Tomorrow, The Flash, Riverdale and Supergirl; NBC's Blindspot; CBS' God Friended Me and The Red Line; The Chilling Adventures of Sabrina at Netflix; DC Universe's digital service's Doom Patrol and Titans; Lifetime's You; and The CW Seed animated series Freedom Fighters: The Way and Constantine: City of Demons.

"I'm incredibly grateful to Peter Roth, Kevin Tsujihara, [Warners president of business strategy] Craig Hunegs, [exec vp development] Susan Rovner and Brett Paul and everyone else here at Warner Bros. who have provided me with such a wonderful home to tell stories for many years — and now many years to come," Berlanti said. "A lot has changed about TV since I started working in it 20 years ago. But what hasn't changed is how blessed I feel to come to work every day, where I work with the most talented, hardest-working company, executives, showrunners, actors, writers, directors, casts and crews in the business. I'm eternally grateful to all of them and to the audiences that have watched our shows. And finally, I'm thankful for the love, guidance and support I get from my husband, my family and my friends, which make moments like this one possible and all the moments in between the real reward."

The pact should be seen as a win for Warners, which as an indie studio has faced an uphill battle to land series on other broadcast networks outside of The CW (which it co-owns with CBS). Under the deal, Berlanti will continue to develop new projects for Warners and its cable- and digital-focused subsidiaries.

"We could not be more excited to extend our partnership with Greg Berlanti, a true giant in the television industry," Roth said. "Greg has been integral to our success since his return in 2011, and we look forward to continuing our collaboration with him and the entire Berlanti Productions team."

That Berlanti would remain at Warners comes amid an arms race for talent as traditional studios look to compete with deep-pocketed streaming rivals like Netflix, Apple and Amazon as the race to cut through a cluttered landscape of more than 500 scripted originals forces everyone to spend big and go bold.

Most studios and streamers are now having to reshape their the nature of their overall deal structures beyond the former standard one-size-fits-all pacts, which is what Netflix has done with Murphy and Rhimes and Viacom with talent, including Tyler Perry, among others. To that extent, sources say Time Warner has been looking to secure a long-term pact with film and TV producer J.J. Abrams that could include a film pact as well as keep his TV deal with Warners.

Berlanti is repped by WME and Felker Toczek.