Star Trek The Next Generation: Dark Mirror

The Enterprise-D crew is drawn into another dimension and learns that it's the mirror universe first visited by Kirk and three other crewmembers a century earlier. They learn the Empire has found a way to cross the dimensional barrier and intends to invade the Federation and Romulan and Klingon empires, and must find a way to thwart this attempt. 
During a brief stop at one of the outer edges of the galaxy, the Enterprise brings aboard a mission specialist, a Delphine species representative named Commander Hwiii (pronounced Wheee). Hwiii studies hyperstrings, which he theorizes can be used to predict events such as a star about to go nova. 
After Hwiii conducts his studies for a few days, a strange occurrence happens that the crew notices. This is followed by an intruder alert: they find a man in the computer core who should be a biologist, and who also seems to be asleep in his quarters. Picard orders a check of the records about duplicate ship's personnel, and before a briefing, the Enterprise has an encounter with a strange dark-metal-colored ship... which appears to be a duplicate of the Enterprise and has the name "ISS Ent--" along with a registry number "ICC-1701-D", on it. 
At the briefing, Data reports on a century-old classified report of the original Enterprise visit to Halka and the encounter with a parallel universe with an Earth-based empire. They decide that the other Enterprise must be the cause of their transfer between universes and so they must get an away team aboard it to obtain that information. Geordi and O'Brien scheme to use a shuttlecraft to carry Geordi and Deanna over and beam them aboard covertly. Monitoring of leaking communications signals allows them to see what the other ship's interior and crew look like, so uniforms are fashioned for Geordi and Deanna to allow them to resemble their counterparts. 
Once aboard, Geordi and Deanna attempt to download the needed information from the Imperial computer, but Deanna has too many passwords she uses at home to risk giving the wrong one on the Imperial ship; they summon Jean-Luc to either pull them out or come over to order the security chief of the ISS Enterprise, Counselor Deanna Troi, to release the computers. 
Jean-Luc comes over, even though his counterpart has still not been seen on monitored images. The mirror Picard is tricked by Deanna long enough to be sedated by Geordi, and Jean-Luc comes out of hiding, and changes into one of the spare uniforms in the closet. Fortunately, there are no outward physical differences between the two Picards, the two La Forges and the two Trois. 
Jean-Luc plays the part of the empire Picard, going to the bridge, and after surviving an assassination attempt by Wesley Crusher, hits upon the solution in Sick Bay. He programs nanites and turns them loose to attack the computer cores in a selective manner. Jean-Luc prowls his counterpart's quarters, spotting the identical library of books, a nearly-identical painting he was working on a few days before, and inquiring with the computer for historical information. 
Jean-Luc discovers that Spock was executed for treason only a few years after he began effecting some changes, changes which were long since reversed. He discovers that the Empire has been growing in ever larger leaps and has run out of room to expand, since the gaps in the galaxy are so wide that even Empire ships, with their more powerful warp engines, cannot bridge in less than years. The Empire is looking for other expansion options, and someone recalled the Halkan incident. 
Jean-Luc also investigates the record of Picard's command, and discovers that Picard had the Edo "god" destroyed, a continent on Ligon II destroyed to force the planet to surrender, destroyed the Ferengi homeworld population to allow settlement by the Empire, destroyed the lifeform of Velara III, and assorted other atrocities. Jean-Luc also must guard his thoughts from Troi, and withstand the affections of Picard's "captain's woman", Dr. Crusher, without raising suspicion. Most particularly, he finds that a smarmy Riker is after Picard's job, though repeatedly protesting that Picard has Riker's complete support. 
When the computers start failing, Jean-Luc plays a captain enraged about his ship falling apart; Geordi, also playing his part, says the cores need to be released while they're still responding to commands; Jean-Luc orders Troi to input the codes, which she does. 
Geordi then plays for time with a complex chip swapping method to restore one core, but his counterpart's assistant, Eileen Hessan, notices one of Geordi's beamouts of chips back to the Enterprise, and alerts Troi. Troi realizes Geordi is the counterpart, not the proper Empire officer, removes his subcutaneous transponder with a crude surgery by dagger, and sends him to the agony booth for interrogation. There, she learns that Picard's counterpart also is aboard, but she misinterprets Geordi's blurt-out of "Counselor" as a plea for mercy. Troi heads for the lower decks to find Picard. 
Jean-Luc, meanwhile, has to keep his counterpart from awakening from slumber and setting off the alert; the two are in a struggle before Jean-Luc has the upper hand and stuns his savage counterpart with a phaser blast, only to hear a phaser blast in the corridor. Jean-Luc emerges to find that Troi or her henchman has disintegrated Picard's personal guard, Lt. Barclay. Jean-Luc's rage is genuine, and he leaves a discomfited Troi. Meanwhile, Deanna has masqueraded as Troi to get Geordi out of the agony booth. The three meet at the top of one computer core, which under Hessan's leadership are rapidly being restored. Geordi downloads the information needed and gets 98 percent when the security goes back up, locking him out. They are beamed back to the shuttlecraft just as Picard and security arrive, and are as promptly beamed from the shuttlecraft to the Enterprise in time as the Imperial ship's phasers destroy the shuttlecraft, which had been cloaked by Geordi's best imitation of a Romulan cloaking device. 
Geordi now must implement the information they stole. Fortunately, Hwiii has been directing the construction of an apparatus that uses some of Hwiii's knowledge, and now Geordi has brought the information that allows them to replicate all the necessary remaining parts and program it. 
The Enterprise is warping away as Hwiii and Geordi lead the final assembly, but soon the Imperial Enterprise has its engines up and running again, and it sets out in pursuit. The first test of the apparatus fails, while Jean-Luc has a conversation instigated when Picard hails the Enterprise from the Imperial ship. When the second test succeeds, the Enterprise then prepares to cross over back to its own universe, and succeeds. Seconds later, the Imperial ship arrives as well. 
The Enterprise, at Geordi and Hwiii's suggestion, makes for a nearby brown dwarf, intending to use its mass together with the equipment of the Enterprise to create a catapult. To power it, they will let the Imperial ship lance at them with its hideously-overpowered phasers, storing energy for the catapult effect. After the ISS Enterprise has raked the Enterprise enough, the apparatus is triggered, catapulting the Imperial ship back into its universe, then when Hwiii gives the word, the Enterprise heads off on a random vector to prevent the Imperial ship from getting a track on them again through hyperstrings. (The Imperials might not understand hyperstrings, but their equipment seems to hit upon them to do its thing.) 
Now, Starfleet can equip each base around the Federation with the equipment to catapult Imperial ships back to their universe.