Star Trek: The Trouble With Tribbles

On stardate 4523.3, Captain James T. Kirk and his crew are called to Deep Space Station K7 by a priority-one distress call. The station is near Sherman's Planet, a world in a sector of space disputed between the Federation and the Klingon Empire. Under the terms of the Organian Peace Treaty, Sherman's Planet would be awarded to whichever side demonstrates that it can manage it most efficiently.
Kirk is furious when he later realizes the distress call was unwarranted, and the undersecretary in charge of agriculture in the sector, Nilz Baris, simply wants someone to guard the shipments of quadro-triticale, a four-lobed wheat/rye hybrid grain, bound for Sherman's Planet. To Baris's annoyance, Kirk assigns two token guards to the task shortly before learning that Starfleet Command endorses Baris's concerns. A Klingon ship soon arrives at the space station and requests that its crew be granted shore leave, as entitled under the treaty. Kirk tells the Klingon leader Koloth that he may only bring members of his crew down 12 at a time, and that he will provide one security guard for each Klingon who beams down.
Meanwhile, an independent trader, Cyrano Jones, brings some little furry animals called tribbles onto the station to sell; he gives one to Uhura as a marketing ploy. She brings it on board the Enterprise, where it and its offspring are treated as adorable pets. The animals purr a relaxing trill that the crew (even the stoic Mr. Spock) find soothing. Klingons, however, find tribbles very annoying, and the feeling is mutual: tribbles emit an ear-piercing shriek of aggression whenever they are around Klingons.
The "trouble" with the tribbles is that they reproduce far too quickly and are capable of eating a planet barren if their breeding is not controlled; in the words of Dr. McCoy, "they are born pregnant" and threaten to consume all the onboard supplies. The problem is aggravated when it is discovered that the creatures are physically entering essential ship systems, interfering with their functions and consuming any edible contents present. Kirk realizes that if the tribbles are getting into the Enterprise's stores, then they are a direct threat to the grain stores aboard the station. However, upon examining the holds, Kirk learns that it is already too late; the tribbles have indeed eaten the grain--a fact he learns the hard way, by being buried to more than half his own height in tribbles when he opens a hold with an overhead hatch. It appears the mission has ended in a fiasco. On top of that, Koloth wants a formal apology from Kirk, since some of the Enterprise crew members have started, though not without provocation, a western-style fistfight with the Klingon crew in the station's bar.
Spock and McCoy, however, soon discover that around half the tribbles in the hold are dead and many of the rest were dying, alerting the Federation that the grain has been poisoned. Furthermore, the tribbles also give away the identity of a surgically-altered Klingon agent responsible. The saboteur is the only "human" the tribbles don't like: Arne Darvin, Baris's own assistant. He had infected the grain with a virus that becomes an inert material in an organism's bloodstream; the more that is eaten, the more inert matter builds up, till the organism cannot take in enough nourishment to survive and essentially starves to death. Upon a medical scan by Dr. McCoy, it is revealed that Darvin is indeed a Klingon in disguise. Thus the tribbles redeem themselves and enable the Federation to score a diplomatic victory against the Klingons. As for Cyrano Jones, who introduced the species to the station, he is ordered to remove the tribbles from the station (a clean-up task that Spock estimates will take 17.9 years) or be imprisoned for 20 years for transporting a dangerous life-form off its native planet.
Just before the Klingon departure, all tribbles that were on the Enterprise are somehow beamed onto the Klingon ship by Scotty as a retaliation for the troubles the Klingons have caused, where, in his words, "they'll be no tribble at all."