In year 689 of the Tang Dynasty, Wu Zetian is to be crowned the first Empress in China despite opposition from Tang officials. She has a Guan Yin figure built overlooking her palace in Luoyang, but an official inspecting the progress mysteriously erupts into flames. Penal officer Pei Donglai and his superior investigate and interrogate the supervising builder, Shatuo, who was formerly imprisoned after he took part in a rebellion. They find nothing and Pei’s superior also dies soon after by also erupting into flames.
The Empress orders former detective and rebel Di Renjie be released from prison after the Imperial Abbot states that he must solve the mystery of the fire. She sends her attendant Shangguan Jing’er to fetch Di from prison, and Jing’er arrives just as Di is being attacked by assassins. Wu reinstates Di as the royal detective and assigns Jing’er to be both an assistant and spy. Jing’er attempts to seduce Di, but is interrupted by assassins. Di meets Prince Li, who fails to recruit him into leading a rebel army. When Pei takes Di and Jing’er to inspect the charred corpses, Di deduces the assassins use a poison that ignites upon contact with sunlight.
Pei joins Di in his investigation. Di reunites with his friend Shatuo, who suspects the poison to be the venom of “fire beetles”. He points Di to Donkey Wang, who is hiding in a network of caverns called the Phantom Bazaar. Pei orders Shatuo arrested for not telling him of this before, but Di stops him. Di, Pei and Jing’er locate Dr. Wang At the Phantom Bazaar, but are attacked by a figure who seems to be the Imperial Abbot. After Jing’er and Pei fight him, Pei pursues him to the Abbot’s forbidden residence. Donkey Wang reveals that he was the court physician and tried to use fire beetles as medicine for the late Emperor. Learning their true danger, he disguised his appearance using acupoints and fled.
Prince Li returns Di’s mace to him, which was taken after he was imprisoned. Di maintains his political neutrality, and Li is assassinated soon after. Di suspects the Abbot’s involvement, but Wu warns him that he will be killed if he attempts to enter the monastery. Pei finds the first inspector had discovered something in his inspection and takes the diagrams, but he is captured. At the monastery, Di learns that the Imperial Abbot is actually Jing’er disguised using acupoints. Di speculates that the Empress used the Imperial Abbot to justify her tyranny and eliminate her political opponents, possibly including the late Emperor. Jing’er attacks Di, but is unable to kill him. She stumbles into a trap set by the assassins and is mortally wounded. Di fulfills her final request by sending her back to court, and she dies in the Empress’s arms.
Di finds Pei, but Pei has already been poisoned by the fire beetle venom and Di is unable to save him. Before he dies, Pei directs Di to the diagrams, which implicate Shatuo. When Di confronts Shatuo at the Buddha, Shatuo reveals his plan to kill the Empress by collapsing the Buddha upon the palace as revenge. He killed both the officials after they noticed his changes to the Buddha and Prince Li for insulting him. He also took the late Prince Li’s authority to use Li’s army to invade the city and kill Wu if she survives. As Di and Shatuo fight, Di is drenched in the fire beetle poison. Di is able to divert the statue, and Shatuo heads to the coronation to poison Wu. Di catches up with Shatuo and spills the poison on him instead, causing him to burn to death in the sun.
Di saves Wu from the collapsing statue and warns her of the rebel army. The Empress promises to be a just ruler and to return power to the Tang Dynasty when her reign ends. Refusing Wu’s offer of a place in her court, Di resigns as inspector and retreats into the Phantom Bazaar with Dr. Wang, where he will struggle to live on with his incurable condition.
Andy Lau plays Di Renjie, an exiled detective of the Tang Dynasty. Lau felt that the character’s psychic abilities was one of his greatest traits
Carina Lau plays Wu Zetian, the Tang Dynasty empress of China.
Li Bingbing plays Shangguan Jing’er, a highly skilled martial artist, who serves as Wu Zetian’s maid and right-hand woman.
Deng Chao as Pei Donglai, an albino officer serving the empress.
Tony Leung Ka-fai as Shatuo, a former friend of Di’s who is now working on the construction of a massive Buddha statue.