The Devil Complex is the fourteenth episode of the fifth season of the television series Agents of S.H.I.E.L.D., and the one-hundred and second episode overall.
As Fitz and Simmons race to find a way to seal the Rift, they are faced with one of their greatest fears manifested.
While Leo Fitz and Jemma Simmons work on an upgraded version of the Gravity Containment Device to permanently contain the Fear Dimension, they are attacked by an illusion of an astronaut generated out of Simmons' mind. They destroy it, but know that they are running out of time and that more anomalies could occur. They reach out to Daisy Johnson and Deke Shaw for assistance, and Johnson agrees to look for Franklin Hall's research notes.
Meanwhile, Alphonso Mackenzie helps Yo-Yo Rodriguez to control the arms taken from a Sleeper Mech. Rodriguez expresses her wish to return to duty but Mackenzie tells her to take the time to heal.
Shaw finds Fitz working on a Sleeper Mech and offers to help him, but Fitz brutally knocks him unconscious, revealing that he is in fact the Doctor from the Framework. Later, the real Fitz learns that they cannot find anything on Hall's previous work on Gravitonium, much to his anger. Johnson tries to comfort him, saying that he does not have to do all the work by himself. When two cameras go offline, Johnson leaves to investigate.
Remaining alone, a horrified Fitz is confronted by the Doctor, who states that he is there to do what has to be done despite Fitz's reluctance. Fitz is terrified by the vision and hears Simmons calling for help as she, Rodriguez and Mackenzie were attacked by a Sleeper Mech who wounded Mackenzie. Fitz reveals that the Doctor is roaming in the Lighthouse, and they figure out that he intends to go after Johnson. Indeed, while checking on the cameras, Johnson is choked by another Sleeper Mech.
Johnson is taken to the Doctor, who straps her to an operation table and reveals that he wants to remove Johnson's Inhuman Control Device, so she can reclaim her powers, which she can then use to compress the Gravitonium and create the Containment Device they need. As the real Fitz, later followed by Simmons, arrives and tries to stop the Doctor, Johnson, Simmons and Fitz himself realize that the Doctor was not an illusion generated by the Fear Dimension, but that Fitz has hallucinated all along, the dark personality of the Doctor resurfacing at times and making him capture and torture Johnson.
They are joined by the Sleeper Mech the Doctor was previously working on, as well as Shaw. The android holds Simmons at gunpoint, and Fitz figures out that he has no choice but carry on what the Doctor started. Despite Simmons urging him to reconsider due to the risks for both Johnson and the Earth and Johnson telling that she will never forgive him, Fitz forcefully extracts Johnson's inhibitor. Once the procedure is achieved without harm, Fitz instructs Johnson to use her recovered powers on the Gravitonium. A new Containment Device is created and successfully replaces the previous one. Following this success, Fitz surrenders and is locked in a cell.
Simmons later visits Fitz in his cell. She tells Fitz to explain his reasons to Johnson and Mackenzie so that they can forgive him, but Fitz claims he does not deserve it. When Fitz says that he still believes he did the right thing, he is surprised to hear Simmons agreeing, as they need to do hard choices to change the future. After a talk about the uncertain future of their marriage, Simmons leaves Fitz in his cell. She is found by Shaw, who tells her that he has every confidence that their relationship will be all right. As proof, Shaw reveals that he is actually Fitz's and Simmons' grandson, much to the latter's surprise.
In parallel of all those events, Phil Coulson, Melinda May and Piper successfully capture General Hale and her driver, who are taken aboard the Zephyr One to be interrogated by Coulson. Hale claims that she is working for the sake of humanity, although Coulson disbelieves her. As Hale reveals that her capture was actually premeditated, May discovers that her driver is Carl Creel, ready to blow up the Zephyr with a bomb belt.
Facing this new threat, Coulson releases Hale. They are joined by another enemy: Anton Ivanov, who apparently works with the General to avert a global alien threat. Hale requires that Coulson come with them, and although May refuses, Coulson eventually agrees to figure out what Hale's plan is. En route to her base, Hale reveals that she secured Ivanov's severed head, forcing him to cooperate.
Hale appears in a dark room filled with alien symbols. A mysterious figure warns her about the consequences of a potential failure and gives her Odium, a Kree potion. As Hale assures her superior that she will succeed, he concludes his speech with the ominous saying "Hail HYDRA".