The sweepstakes to land a massive overall deal with Bad Robot, the famed production company run by J.J. Abrams and his wife and co-CEO, Katie McGrath, is nearing the finish line.

Following a monthslong courting process that included multiple suitors, WarnerMedia is in final negotiations for a new partnership with Bad Robot, sources say. It's unclear how many years the new agreement is for, as the deal that would keep Abrams with the company he has called home since 2006 has not yet been finalized. Still, sources have estimated that any new pact for Bad Robot could be valued in the $500 million vicinity when all is said and done. That would put the deal at the top of the recent wave of nine-figure pacts for prolific producers, including Greg Berlanti ($400 million from Warner Bros. TV), Ryan Murphy ($300 million from Netflix) and Shonda Rhimes ($100 million from Netflix).

Under the deal, Abrams and company will continue to create and develop new projects for WarnerMedia and supervise other producers across film, TV and digital platforms. Sources say the process of moving Bad Robot's feature film deal over from Viacom-owned Paramount Pictures has already begun.

Representatives for WarnerMedia and Bad Robot declined comment.

The pact arrives after Abrams and Bad Robot were considered the biggest fish in the overall deal waters. Multiple studios and streamers at least kicked the tires or engaged in a hyper-competitive effort to woo Abrams and McGrath on a possible rich pact for the company behind hits including HBO's Westworld and Hulu's Castle Rock, among others. Netflix, Apple, Amazon and fellow media behemoths WarnerMedia, Comcast and Sony Entertainment were among those who, sources say, met or explored a deal with Bad Robot. Sources say Abrams and Bad Robot execs, including head of television Ben Stephenson, took meetings all over town as they considered moving their overall deal from Warner Bros. TV, where the company behind Fringe has been based since 2006. While outlets including Apple and Sony came close, sources stress WarnerMedia emerged on top at least a month ago when it became apparent that Bad Robot prioritized being part of a larger company with TV and film distribution — including WarnerMedia's forthcoming SVOD service.

WarnerMedia, now under the leadership of CEO John Stankey, is among the companies who pulled out all the stops in a bid to keep Abrams in-house. According to multiple sources, one big consideration weighing on Stankey was a desire to keep his prized producer within the company fold. Sources say McGrath — who is also a founding member of Time's Up — conveyed to Stankey in no uncertain terms that Warner Bros. CEO Kevin Tsujihara's continued presence was a "values" issue as she and Abrams explored their company's options. Tsujihara stepped down March 18 following The Hollywood Reporter's publication of texts revealing that the executive had engaged in an affair with British actress Charlotte Kirk and then attempted to help her land roles in Warners' television shows and movies.

Further complicating the bidding process was the ongoing war between the Writers Guild of America and agencies over packaging fees and affiliated studios, with Abrams and Bad Robot having stopped working with representatives at CAA in all areas — save for directing. With CAA no longer leading the charge, the process had slowed considerably in the past couple months, but sources say Abrams continued to meet with Warner Bros. TV Group president Peter Roth and Stankey, with whom he has had an ongoing relationship.

Abrams, who is currently editing Star Wars: Episode IX for Disney, was among the top producers in Warners' TV fold at a time when brand-name showrunners are in increasingly high demand. Warners, Comcast and Disney are planning streaming services in a bid to compete with Netflix, Amazon and Apple, with the latter entering the originals business last year. Netflix helped explode the market for proven hitmakers when it signed Rhimes and, later, Murphy to nine-figure overall deals, prompting both producers to exit their respective longtime homes at ABC Studios and 20th Century Fox Television. Between the ramp-up for content produced in-house for those forthcoming streaming platforms and the feud between writers and agents, demand for top writers and producers has further elevated these already eye-popping mega-deals for top creators.

On the TV side, Abrams is prepping an HBO drama, Lovecraft Country (with Jordan Peele), and also executive produces Castle Rock and Westworld alongside showrunners Lisa Joy and Jonah Nolan. (The latter duo exited their longtime home at Warners for a lucrative five-year, $150 million deal with Amazon Studios.) Abrams also is working on Demimonde, the first series he has written and created since Alias. The genre drama landed at HBO following a multiple-outlet bidding war, with the premium cabler also landing the hot script They Both Die at the End from Abrams and The Other Two breakout Chris Kelly. Abrams and Bad Robot also have three shows in the works at Apple: the Stephen King adaptation Lisey's Story, starring Julianne Moore; Sara Bareilles' Little Voice; and the Jennifer Garner vehicle My Glory Was I Had Such Friends. All three were picked up straight to series amid competition from multiple outlets.

All of those projects are produced by Warner Bros. TV, which last year extended mega-producer Berlanti with an overall deal said to be worth $400 million. Berlanti presently holds the TV record for the most scripted originals currently airing (18).

With WarnerMedia expected to unveil its direct-to-consumer subscription platform in the fourth quarter (in beta), keeping Abrams in the fold was considered a high priority for the independent studio. Following the departure of Joy and Nolan to Amazon, re-upping Bad Robot was increasingly important to the studio, which continues to aggressively pursue top talent. The studio recently signed Mindy Kaling and Ava DuVernay to rich overall deals. For its part, Warners promoted Susan Rovner and Brett Paul to presidents of the TV studio as they take over day-to-day oversight of the unit from longtime exec Roth. Roth, who remains under contract through 2020, will continue to serve on the Warner Bros. interim leadership team alongside Toby Emmerich and Kim Williams during the studio's search for an exec to replace the ousted Tsujihara. Next up for the studio will be inking mega-producer Chuck Lorre (The Big Bang Theory, Young Sheldon, Mom, The Kominsky Method) to a new pact as his overall with WBTV expires in June 2020.

Bad Robot is repped by Jackoway Austen Tyerman.