August 1941: Children are being evacuated to Cardiff during the London Blitz, and Captain Jack Harkness collects a young boy at Cardiff's train station -- a red-haired child whose name tag reads "A. Neil" and who speaks a senseless Cockney word salad. Jack delivers the alien child to the Torchwood Hub, and then, since he has a few days to himself, he tries once again to enter Tretarri, a certain Cardiff neighbourhood that seems barred to him. Once again, he becomes nauseous the moment he sets foot in Tretarri, and is forced to lay low for the next few days. In his absence, his future enemy Bilis Manger appears out of nowhere in a deserted house in Tretarri, and sends a message to Dr Tilda Brennan at the Hub. When Jack returns, he finds that Brennan has vivisected the red-haired alien boy, overpowering the rest of her team when they objected. Her eyes glowing white, Brennan tells Jack that she has a message for him, but she is then distracted and Jack shoots her in the head. Greg Bishop picks up Brennan's diary, hoping to find a clue to her behaviour inside, but the pages are all blank -- and Greg bursts into flame and burns to ash within seconds. A message then appears on the diary's blank pages, a message warning Jack that this is revenge for the future.
Present day: Jack tells his team that he's taking a few days off, and Owen slips up and must admit to Ianto that he sometimes borrows the SUV while Ianto is away; the last time he did so, it got covered in mud, and Owen got Ianto to clean it up by claiming that the mud contained alien spores. Quietly plotting his revenge, Ianto follows Jack to Tretarri, having learned of Jack's strange relationship with the neighbourhood from the Torchwood archives. Jack is reluctant to discuss it, but Ianto insists that Jack's friends want to help him. Back at the Hub, Ianto conducts some research and learns that Tretarri was created by Victorian mine owner Gideon ap Tarri as a home for his workers and their families; it has a history of hauntings and unexplained fires, and reports indicate that Gideon ap Tarri was not buried in his own grave. Tosh heads out to Tretarri to scan it for Rift activity, and finds it undergoing major renovation and reconstruction. The Scheme Manager, Ifan Daffydd, gives Tosh a quick tour and tells her that his team are fitting the neighbourhood out with state-of-the-art wireless routers and street lighting, without disturbing any historically significant sites. The work is due to be completed within a day, and the Admin staff at City Hall have planned a street party to celebrate. Tosh discovers that the reconstruction is being overseen by Bilis Manger, but before she can warn her friends, Bilis himself appears and knocks her unconscious.
Gwen meets Rhys for lunch, and is horrified when he hands her a business card that Bilis Manger asked him to pass on to her -- with a written note referring to her as the Widow Williams. Telling Rhys to go find his friends and stay with them, Gwen rushes back to the Hub. Meanwhile, Jack visits City Hall to speak with Idris Hopper, who met Jack briefly on the day Mayor Margaret Blaine disappeared. Idris later spotted Jack in the Oval Basin, and was so determined to get answers from him that he saw through the invisible lift's perception filter. Jack tried to slip Idris some retcon, but the pill didn't work on him, and he's never forgiven Jack for trying to trick him and erase his memories. Nevertheless, he agrees to give Jack all the information he has on the Tretarri redevelopment project -- and Jack thus learns of Bilis Manger's involvement.
Ianto turns up a police report from 1986; four students broke into 6 Coburg Street to investigate claims that the house was haunted, and only two, Owain and Janet, came out again. Owain claims that his friends Michele and Martin's eyes began to low when they started playing with a Ouija board; the board spelled out the words "torch" and "wood," and Michele spoke of the darkness, the light, and a woman named Phyllis. Owain and Janet fled the house after seeing the ghost of an old man, and believe that their friends spontaneously combusted. The police were forced to let the two go due to lack of evidence, but remained convinced that the students had set their friends on fire. However, when Jack and Gwen return to the Hub, Ianto realises who the ghostly old man was; Michele wasn't saying "Phyllis," but "Bilis".
Since Jack has been unable to enter Tretarri since before he began working for Torchwood, Ianto and Owen suggest that the force keeping him out may be related to his past as a time traveller. Before they can investigate, however, Bilis materialises in the Hub and offers to trade Tosh for the opportunity to resurrect Abaddon using the Rift. Jack refuses, and Bilis vanishes again. Playing a hunch, Jack visits the Vaults where Bilis murdered an alternative version of Rhys Williams, and finds Bilis waiting and watching Janet the Weevil. Bilis gives Jack a cryptic warning about Owen's future, tells Jack that Tosh is at 6 Coburg Street, and vanishes again. For a moment, Jack has a vision of Greg Bishop warning him about the light and the darkness, and Greg then vanishes as well. The only sign that anyone has been there is a note stuck to Janet's cell, with the phrase "Revenge for the Future" written in blood.
Tosh awakens to find herself in what appears to be Bilis's shop, A Stitch in Time. Bilis reveals that he's suspended her between moments of Time so that he can reveal her potential to her. He grabs her hands, granting her a vision of a future in which she and Owen are married and in charge of Torchwood -- and in which Jack has been sealed in a glass cube and wired up to the Rift Manipulator, giving Tosh and Owen control over the Rift and the ability to take over the world. A ragged Ianto bursts into Torchwood's new headquarters and shoots Owen in the head, and the security guards, reacting a moment too late, riddle Ianto with bullets. The vision ends as the future Tosh orders her guards to take Owen to her office. Present-day Tosh's body then fills with light, as Bilis warns her that there is a price to be paid for making deals with the Light and the Dark.
Gwen discovers that Bilis Manger, though not a member of Torchwood, has been granted official access to all of Torchwood's facilities. Jack is unable to contact Archie, the man in charge of Torchwood Glasgow; this may not have anything to do with the current crisis, however, as the eccentric Archie has little grasp of modern technology and once accidentally revealed the existence of the Loch Ness Monster by sending a photograph to the wrong person. Jack visits Idris Hopper again while Gwen and Ianto head out to Tretarri and Owen remains at the Hub to test a sample of Jack's blood. On the way to Tretarri, Gwen tries to cheer up Ianto by asking him about his relationship with Jack, but Ianto reveals that his bisexuality makes him feel awkward and alienated from everyone around him. He and Gwen are able to enter Tretarri with no ill effects, but they suddenly freeze in position as Bilis steps out of 6 Coburg Street -- and as Tosh emerges with him, her face half painted with clown makeup, Gwen and Ianto begin to fill up with light. Back at the Hub, Owen visits the Vaults to vent his frustrations before the trapped Janet, but while doing so he has a eureka moment: Jack has been kept out of Tretarri because it's being set up as a trap, which is finally being sprung. Before Owen can contact Jack, however, Bilis overpowers and captures him as well.
Knowing that Idris Hopper is a bibliophile, Jack asks him to take a look at Tilda Brennan's mysteriously blank diary. Idris promptly points out the obvious: it's not blank, the entries have been written in invisible ink. He agrees to try deciphering it, but warns Jack that it will take about three hours. Jack leaves him to it, but then has another vision of Greg Bishop warning him that his team has been captured. Jack rushes back to the Hub to find that Bilis Manger has locked him out, and Bilis lures him to a bar at the Millennium Centre, where he reveals that his god Abaddon served even higher powers -- and that the Light and the Dark were freed when Jack destroyed Abaddon. All will be revealed tomorrow when Jack is finally permitted to enter Tretarri. Bilis vanishes, and Jack climbs to the roof of the Millennium Stadium to brood; there, he sees light and dark energy playing around the stadium antenna, and as Cardiff suffers a temporary blackout, the face of Greg Bishop materialises in the energy and tells Jack that the answer lies in the diary. Meanwhile, Idris finishes his work and visits the information kiosk; Bilis is waiting there, and Idris, unaware of the old man's identity, gives him a message to pass on to Jack.
1876: On the streets of Tretarri, Gideon Tarry witnesses a cosmic confrontation between two demons, Abaddon and Pwccm. The beasts sink back into the earth after their battle, and their human servants, identical twins Bilis and Cafard Manger, seem to merge into one being before Gideon's eyes. Bilis tells Gideon to write about this incident in his diary and to keep it safe from those who would take it from him -- particularly an organisation called Torchwood, which will one day destroy the future. Gideon does as Bilis requests, and arranges for his diary to be buried with him when he dies.
Present day: Once day breaks, Jack returns to Tretarri, where the street party is in full swing. When he sees Owen and Ianto dressed as clowns and mingling with the partygoers, he pushes through the nausea barrier, which finally gives way for him. Bilis is waiting for him on Coburg Street, where he invites Jack to enter number 6 and discuss a matter of revenge. Idris Hopper also arrives in Tretarri, unsure what impulse has drawn him here -- and unaware that the street performers at the party are Gwen, Ianto, and Tosh, who have been mesmerised by Bilis and given visions of the future...
The future: Owen briefly opens and closes the Rift, just long enough to grasp its potential to change the world. When he claims that he has nothing else to live for, Tosh kisses him -- and the power that possessed Owen when he looked into the Rift passes into her as well. Although Gwen is not fully possessed, she is pregnant, and the hormones raging in her body leave her vulnerable to the power's influence. She thus stands by and allows Owen and Tosh to overpower Jack and wire him into the Rift Manipulator, using his limitless life energy to harness the power of the Rift. With this at their disposal, they use the alien technology in the Vaults to take over the world, uniting it in the name of the Torchwood Empire. When Ianto protests, they destroy the Hub and move their base of operations to another part of the city. Ianto contacts Rhys, manages to convince him that Gwen is under an alien influence, and promises to ensure her safety in exchange for the security codes he needs to get into the new Torchwood HQ. He keeps his promise and waits until Gwen is giving birth in hospital before he attacks Torchwood HQ, shoots Owen and is himself killed by Tosh's guards.
Present day: Bilis explains to Jack that elemental forces of Light and Dark are at war within the Rift, and the demons Abaddon and Pwccm are their champions. When Jack killed Abaddon this gave the Dark the upper hand, and Torchwood's actions in the future will enable the Dark to escape from the Rift and take over the world. Bilis has stored some Light in Gideon's diary, which Gideon hid for him until the time was right; Greg Bishop died in 1941, partly as an act of pre-emptive revenge for what Jack would do in the future, and partly because he simply got too close to the Light and was incinerated by it. Bilis now needs Jack's help to release the rest of the Light back into the Rift and trap the Dark in a secure wooden box, restoring the balance of the elements.
Jack doesn't believe Bilis's story until he walks out of the house to see that everyone attending the party, including his teammates, has now been possessed by the Light and the Dark that has lain dormant beneath Tretarri since 1876. Bilis grants Jack the vision that his friends are experiencing, a vision of the Torchwood Empire and of Ianto's death. Ianto is riddled with bullets before the new Rift Manipulator, and when the imprisoned Jack sees this, his rage and grief gives him the power to rip free of his bonds. He then grabs a security guard's weapon and shoots the Rift Manipulator. The explosion takes out Torchwood's new HQ; only Gwen and Rhys survive, safe in the hospital, where Gwen is freed from the influence of the Dark the moment the Rift Manipulator explodes.
Gwen and Ianto awaken from their nightmarish visions of the future, and are reunited with Jack and Bilis -- and Idris, who has resisted possession by the elemental forces. They enter 6 Coburg Street, which Gwen momentarily sees as A Stitch in Time due to the influence of the perception filter that kept the house safe for Bilis until the moment when it was needed. Bilis uses the diary to draw the Light out of the partygoers, explaining that he arranged the reconstruction and street party in order to lure human hosts who would store the Light until he was ready to release it. Unfortunately, he didn't anticipate that the Dark would also possess some of the partygoers, and he can't afford to draw it out of Owen and Tosh for fear that it will read his mind and learn his plan to defeat it. Idris thus volunteers to host the Dark while Bilis and Torchwood set their plan in motion.
Bilis transfers the Dark particles out of Owen and Tosh and into Idris, and Jack sends the shaken Owen and Tosh back to the Hub to wire Bilis's containment box up to the Rift Manipulator. Bilis watches over the possessed Idris while Jack, Gwen, and Ianto travel to the Millennium Stadium and use the antenna to fine-tune the power of the Rift. As Bilis had intended, the Millennium Stadium's antenna draws in all of the Dark particles currently possessing human hosts, including Idris, but when the Dark tries to pour through the aerial into the Rift, it is instead diverted into the containment box. Bilis then releases the Light from the diary, and it pours through the Rift to restore the balance and keep the demon Pwccm trapped inside. Once the Light and the Dark have gone, the Torchwood operatives return to Tretarri to find that earthquakes and fires have reduced the neighbourhood to rubble. Most of the partygoers have fled, Bilis has vanished, and the dazed Idris asks Jack to give him the most powerful amnesia pill that Torchwood has, in the hope that it will work this time. Jack does so, and he and the others return to the Hub to encase the box of Dark in a block of concrete.
Three weeks later, Idris gets a phone call out of the blue offering him a new job in Berlin, and decides that the time has come to broaden his horizons. As he boards the plane, he sees Jack watching him from a distance, but doesn't remember who he is. He also doesn't remember Bilis Manger when the old man sits next to him on the plane, carrying a wooden box and telling Idris that he is taking his Lord's ashes away to be interred elsewhere.