A man's body is found burned beyond recognition inside a building that was set ablaze by an arsonist. Lieutenant Delia Burton of FDNY reports to Castle and Beckett that no accelerant is found on the corpse that houses a bullet wound. The building's owner has mob ties, but claims he didn't torch his place for an insurance payout. Back at the crime scene, Delia finds an "X" mark in the floor under the charred carpeting. This leads her to believe that the victim was a fire investigator. His name was Blake McCann. He was her partner.
Delia says the "X" pattern she saw at the building was from an accelerant found by her partner in many other buildings. It's the work of a serial arsonist who has been dubbed "The Phantom." McCann put away an arsonist named Adam Ferguson who got out of prison five years ago. The two of them were in contact with each other recently. Ferguson claims McCann asked him for help to catch the Phantom. The parolee says this particular arsonist knows what he's doing when it comes to fire. He likes to watch his work. Castle finds a video online that may have been posted by the killer.
Ryan and Esposito check out a building that was part of McCann's files. They find a work area that suggests this place is the arsonist's workshop. The detectives set off a booby trap that causes a massive explosion. In other news, the website that posted the video Castle found is run by a man named Milo Pavlic, who says he doesn't know the identity of the mystery videographer. The guy gets a text about a new fire raging in the city. Castle and Beckett realize it's the building their partners were investigating.
Ryan's wife, Jenny, is three days past her due date. Beckett has no choice but to tell her what's happening as the fire rages on. It's too dangerous to send in rescue workers even though two of New York's finest are trapped inside. Captain Gates and Delia give the entire precinct up to speed on the case. The hunt is on for this sick individual is on. Inside the building, Esposito awakens. Ryan is also alive, but his legs are trapped. There's no way he can get free. Ryan wants Esposito to get out of the building before the ceiling gives. That's not gonna happen. Espo isn't going anywhere without his partner.
Esposito manages to free Ryan, but they are still trapped in a basement area with no cell phone use. They bang pipes hoping someone outside will hear. This doesn't work. Outside, the fire department is pulling back. This is no longer a rescue operation. It's a recovery. Jenny arrives at the scene. She's in labor. She's also not leaving without her husband. Moments later, Ryan is able to call Beckett. They are about 20 feet down. Castle believes that since this was the arsonist's lair, he must have planned an escape route. They need to find this guy. It's the only way they'll find a way out for Ryan and Esposito.
Captain Gates grills Milo Pavlic about the arsonist. The guy used to say that sick and dying buildings need to be put out of their misery. Inside, the carbon monoxide is getting to deadly levels. Ryan knows he might not make it. He asks to talk to Jenny. He needs to tell her he loves her. He needs to say goodbye. Ryan helps his wife pick a name for their baby. If it's a boy, it'll be Javier. If it's a girl, it'll be Sarah Grace after Jenny's grandmother. The line goes dead. Jenny is devastated. Castle, Beckett and Lanie are heartbroken.
Esposito falls asleep due to the carbon monoxide. Ryan desperately tries to wake him while also searching for a way out. He doesn't want to leave Jenny. Outside, Delia helps Castle and Beckett realize that the building inspector they met at the murder scene, Mark Kimball, is the arsonist. He's caught at the scene. Beckett says if her friends die, he dies. Inside, Ryan and Esposito are unconscious when the interior wall is broken down by a fire rescue team. Moments later, Ryan and Esposito emerge from the building. Both are alive and one is also a new dad. Detective Kevin Ryan rushes to his wife's side where he meets his brand new daughter: Sarah Grace.