One of the most shocking changes in the new reality of Earth-Prime was Lex Luthor's retcon as the founder of the D.E.O. and a publicly hailed national hero. And, in an upcoming episode of Supergirl, Lex's rise to power and his master plan will be explored.

The CW has released the official synopsis for Supergirl Season 5's return episode, titled "Deus Lex Machina," which also marks star Melissa Benoist's directorial debut. As Lex plots to pit Supergirl against their mutual antagonist Leviathan, the nefarious figure moves toward growing closer with his estranged younger sister Lena.

RELATED: Supergirl: Dreamer's Visions Will Have 'More Impact' as S5 Wraps Up

MELISSA BENOIST MAKES HER DIRECTORIAL DEBUT – Lex (guest star Jon Cryer) proceeds to lay an intricate plan to bring Lena (Katie McGrath) closer to him, defeat Leviathan’s latest attack, and pit Supergirl (Melissa Benoist) and team against Leviathan. It is also revealed how Lex came into power after Crisis. Melissa Benoist directed the episode with story by Lindsay Sturman and teleplay by Katie Rose Rogers & Brooke Pohl (#517). Original airdate 5/3/2020.

Leviathan has served as the primary antagonist for much of Season 5 while Kara navigated her ruptured friendship with Lena over her secret identity. Upon his resurrection during the "Crisis," Lex dedicated his time to combat Leviathan while quietly consolidating power.

RELATED: Supergirl: Dreamer's Transphobia Storyline Was Long Overdue

With principal photography on the season finale shut down due to the ongoing coronavirus (COVID-19) pandemic, star Jon Cryer hinted that the finale would be rewritten to change how his character may be defeated.

Returning Sunday, May 3 at 9 p.m. ET/PT on The CW, Supergirl stars Melissa Benoist as Kara Danvers, David Harewood as Martian Manhunter and Chyler Leigh as Alex Danvers.