"Chain of Command" was the 10th episode of the sixth season. It was written by Frank Abatemarco and Ronald D. Moore.
Captain Picard is relieved from command of the Enterprise by Admiral Nechayev. He is reassigned, along with Lt. Worf and Dr. Crusher, to go undercover and find a Cardassian laboratory where Starfleet suspects them of making a biological weapon that eats DNA of living species while leaving infrastructure intact. This allows for the taking over of planets without the addition of conflict with the inhabitants.
In their search, they discover an installation that was believed to be the lab, but instead find it was a trap to lure them and imprison them. Crusher escapes with the help of Worf, but Picard is left behind.
Meanwhile, the Enterprise crew is trying to get used to, and live up to the expectations of, their new captain. He is Captain Jellico (played by Ronny Cox) and he's by-the-book, no nonsense, and a source of irritation to the senior staff. He has clashes with Riker, who feels their top priority is to go on a rescue mission to find Picard when they learn from a Cardassian they have been in negotiations with that he is in the custody of Cardassian authority. Jellico will have none of it, instead insisting they need to complete the mission of ensuring the Cardassians don't attack a federation colony. Jellico relieves Riker of duty for insubordination, only to reinstate him later when he needs an experienced shuttle pilot to plant mines across a nebula where Cardassian ships are hiding.
Back to Picard, who is undergoing torture by an interrogator named Gul Madred (played by David Warner). He is strung up naked, starved, and administered intense pain from an implanted device in his upper chest. When Madred gets an answer he doesn't like, he shocks Picard. He torments him with offers of water but doesn't deliver. He feeds him eggs with live creatures inside.
"There are four lights" Picard says when asked by Madred how many lights he sees. Madred shocks him and tells him there are five lights. He asks him again, "How many lights are there?" Picard is shocked again when he says there are only four.
Madred also lies to Picard and tells him they have the doctor in their custody and will interrogate her if Picard chooses to leave. Madred gives Picard the option of living in luxary or continuing the torture after he is told Cardassian ships destroyed the Enterprise.
When the captain of a Cardassian ship is informed of the mines in the nebula by Jellico, and given a small demonstration as proof, the Cardassian ships withdraw and agree to release Picard. The Cardassian guards arrive at a crucial moment---when Picard is asked once more how many lights he sees. The guards inform Madred of their agreement with the federation and Picard shouts "There are four lights!"
Back aboard the Enterprise, their mission is complete and Picard is reinstated as its captain. He tells Counselor Troi he thought he saw five lights and was about to confess that to Madred before his release.
This was one of the darkest episodes of TNG. It's not about strange phenomenon in space, or cutesy relationships, or discovering new species. This one is about two factions on the brink of war and the consequences that it entails. It depicts disturbing scenes of torture and humiliation. There's no pleasantries in this episode, but it's well-acted and written--and unforgettable.
This episode is a tribute to the great talent that is Patrick Stewart.