Stardate 4523.3: Kirk and Spock have Chekov provide a briefing on their approach to Space Station K-7 which is near Sherman's Planet and the fact it is disputed between the Federation and the Klingons. They're interrupted by a priority one distress signal from K-7 as they go to red alert.
The Enterprise approaches K-7… but there's nothing to be seen. They contact the base commander, Mr. Lurry. Lurry refuses to explain what the problem is and asks them to come over. Spock and Kirk arrive where they meet with Nilz Baris, the undersecretary of agricultural affairs, and his assistant Arne Darvin. Baris wants them to protect quadotriticale--bio-engineered wheat and the only thing that will grow on Sherman's Planet. Kirk isn't happy at having the Enterprise being redirected to guard wheat. Kirk reluctantly gives in and assigns two security guards, while authorizing shore leave. Baris is not amused.
Chekov and Uhura arrive for shore leave and stop in on a trader, Cyrano Jones, arguing with a bartender about his buying a stock of "tribbles"--small living balls of fur. Uhura takes a liking to them and sets one down, where it starts eating the grain sample they have. The bartender agrees to buy them from Jones and he gives his sample to Uhura.
Later Kirk gets a transmission from Admiral Fitzpatrick who reminds him of the importance to Sherman's Planet, and tells him to give Baris all cooperation. After Fitzpatrick signs out, they pick up a Klingon battle cruiser approaching the station. They go to red alert but the ship does nothing. Lurry calls to tell them that the Klingon commander and his first officer are in his office.
Kirk and Spock arrive and it's clear he and the Klingon commander, Koloth, know each other. Koloth wants shore leave and under the terms of the Organian peace treaty, they must agree to him. Lurry has no choice but to agree and Kirk only lets him bring ten minute over, and each one will have a security guard accompanying him.
Later in the mess hall, Kirk and Spock find that Uhura's tribble has had babies, and she give them out to the crew while McCoy takes one for study. Baris contacts Kirk and isn't happy with the Klingons but Kirk is not impressed. He heads to Sickbay for a headache cure and finds that McCoy's tribble has bred again.
On the station, Scotty and Chekov are enjoying a drink while the Klingon first officer Korax tries to pick a fight after the tribble reacts badly to him. He taunts Chekov but Scotty tells him to back down… until Korax insults the Enterprise. Scotty throws the first punch and a fight breaks out until security breaks it up. Later no one tells Kirk who was responsible and he confines them to quarters, until Scotty confesses, saying he was defending the Enterprise. Scotty is more then to be glad to be confined to quarters so he can catch up on his technical reading.
The tribbles continue to breed and Spock can't see any reason for them, over McCoy's objections. Kirk finds them all over the bridge and McCoy warns that they're born pregnant. Spock confirms that the tribbles will soon overwhelm the ship, and Kirk calls for a meeting with Lurry and Jones. Jones denying anything wrong and he departs as Baris and Darvin arrive to protest. Baris thinks Jones is a Klingon agent but Jones' record is clean.
Back aboard the Enterprise, Kirk and Spock find the tribbles are all over the place and into the food processors as well. They realize that the tribbles got in through the air vents… and there are air vents to the quadrotriticale storage bins. They go back to the station and Kirk opens one of the bins… only to have thousands of tribbles fall on him.
Baris is furious and Kirk isn't too thrilled either. McCoy comes in to announce that they won't breed if they don't eat. They realize the tribbles are dead and McCoy goes to determine the cause.
Kirk calls for a meeting and has Cyrano Jones and the Klingons brought in. Koloth wants to file a complaint and get an apology, which he thinks will give the Klingons control of Sherman's Planet. Kirk wants answers, but Koloth asks that the tribbles be removed. As the security guards take them out, Darvin comes in… and the tribbles react to him the same way as they did to the Klingons in the bar earlier. Kirk tests their new theory and discovers that the tribbles like everyone except Klingons… and Darvin.
McCoy arrives and determines Darvin is a cosmetically-altered Klingon. McCoy also announces the quadrotriticale was poisoned with an inert substance that builds up in the digestive system, causing the victim to starve to death. Kirk uses the tribbles to interrogate Darvin who quickly admits he poisoned the grain. They take him off and Kirk tells Koloth to get out of Federation territory.
Back at the bar, Kirk shows Jones that the place has been overrun by tribbles and decides to give him a break… by having him pick up every tribble in lieu of imprisonment. Jones has no choice and starts to work.
Back aboard the Enterprise, Kirk comes on the bridge to find that the tribbles are gone. No one is willing to take credit for the clean up… until finally Scotty admits that he beamed the tribbles over to the Klingon ship as it left… where they'll be no tribble at all.