As it escorts two robot grain ships to Sherman's Planet, a world ravaged by crop failures and famine, the Enterprise breaks course to track a Klingon battle cruiser that is pursuing a one-man scout ship. When the Klingons fire on the smaller vessel, Kirk instructs Scotty to beam out the pilot, but the Klingon blast decalibrates the integration parameters. Using a dangerous new weapon — a projected stasis field effect that disrupts ship's engines and weapons — the Klingons fire on the Enterprise and cripple it.
Klingon Captain Koloth hails the Enterprise and tells Kirk that the man caught in the decalibrated transporter beam has committed an act of ecological sabotage, and threatens to take him by force. Kirk sends the two grain ships on a ramming course for the battle cruiser, and Koloth's attempts to stop the other two vessels drains too much of their power, though one grain ship is damaged.
The crisis averted for a moment, Kirk moves to the transporter room, only to discover that the rescued pilot is trader Cyrano Jones ... and he's brought piles of puffy pink tribbles with him! Jones claims that he's had the tribbles genetically engineered so that they don't reproduce, making them "safe." He also shows them a tribble predator known as a glommer, and tells them that he inadvertently sold the Klingons some tribbles, thus causing the "ecological sabotage" to which Koloth referred.
Having transferred the important quintotriticale grain to the holds of the Enterprise, Kirk and his crew are dismayed when Koloth returns, and wrecks the propulsion units of the other grain ship. When the Federation starship is fired upon again, the quintotriticale spills in the corridors, and the tribbles feed on it, growing to a size so massive that the glommer can no longer devour them. As the oversize furballs intrude throughout the ship, Koloth returns and catches the Enterprise in its stasis field again. But when Koloth prepares to board the Enterprise to capture Cyrano Jones, Scotty beams over all the gigantic tribbles to the battle cruiser!
Immobilized by tribbles, Koloth tells Kirk that Jones stole the glommer from them, and that the prototype creature — an artificial lifeform — is necessary to help rid the Klingon world of the tribbles Jones unleashed there. Kirk returns the glommer to the Klingons, and McCoy finds that a shot of neoethylene will break the giant tribbles down into smaller colonies. And, as Scotty says, if they must have tribbles, it's best to have little ones.