Star Trek: Operation: Annihilate

On stardate 3287.2, the starship USS Enterprise, under the command of Captain James T. Kirk, is sent to investigate Deneva, a colony of one million people, with which the United Federation of Planets has lost contact. Kirk is especially concerned about the colony because his brother Sam, a research biologist, resides there with his family. Kirk refers to the colony as one of the most beautiful planets he has ever seen.
Mr. Spock finds computer records that indicate an epidemic of mass insanity has been spreading through several planetary colonies in the sector, starting with Beta Portalin, and Lavinius V, then Theta Cygni XII, and Ingraham B in recent years.
Before the Enterprise achieves orbit around Deneva, sensors detect a Denevan ship on a suicide course straight into the sun. An attempt is made to contact the ship's pilot, but all he indicates is that he is "finally free", just before his craft is vaporized. Lt. Nyota Uhura then picks up a distraught message from Aurelan, Kirk's sister-in-law, who pleads for help and then is cut off.
Not wasting time, Kirk beams down with a landing party and security force. They are soon met by a group of men armed with clubs who take a threatening stance, however the men's words are at odds with their actions. They keep saying they don't want to harm the party yet continue to threaten them. The party stuns the attackers with their phasers, then moves on.
The party then responds to a woman's scream, finding Kirk's brother Sam, who is dead, Sam's wife Aurelan, hysterical, and their son Peter, still alive but unconscious. Kirk has them beamed aboard the Enterprise for treatment and hopefully more insight as to what is happening. Once aboard the Enterprise, Aurelan responds only about "invaders" which cause them pain. Aurelan claims a ship from Ingraham B brought "things, horrible things" that had forced the crew to do their bidding, and they had then spread over the colony. They began forcing the people to build them ships so that they could take over more colonies. As Aurelan speaks, the health monitors detect sudden spikes of agonizing pain that occur as she tries to inform the officers of the problem. Eventually the pain is too much and she dies.
Returning to the planet, a landing party including Kirk, Spock and Dr. Leonard McCoy check out a nearby building. Upon entering, they discover hundreds of the strange, giant-amoeba-like parasites (which look like globs of melted plastic or badly fried eggs) clinging to the walls and ceiling. They can move short distances through the air. The creatures do not show up on tricorder scans and they are resistant to phaser fire. Kirk decides to retreat. As the team exits, a creature that had been shot by a phaser blast rallies and attaches itself to Spock's back. Spock collapses in pain and Kirk rushes to help him and orders an immediate beam out and returns to the ship.
Back in sickbay, McCoy closely monitors Spock, discovering the creature has grown new tissue around Spock's nerves which is far too complex for conventional surgery to remove. Mr. Spock awakens and rushes to the bridge to take control of the ship. He is subdued and tranquilized. Later he recovers on his own, and says he is using his Vulcan mind control to overcome the pain and is now ready to return to duty. Kirk thinks otherwise, but Spock explains he must return to the planet to capture a parasite specimen, and work on a way to stop them. Eventually, Spock calmly breaks free and attempts to transport to the planet only to be stopped by Scotty who calls for Kirk. Spock says he is the logical choice to send down since he is already infected by the parasite tissue, and more able to withstand the controlling pain than a human.
Kirk reluctantly agrees and sends Spock down. When Spock arrives he is attacked by a pipe-wielding Denevan, but quickly subdues the assailant, and makes his way to the building where the parasites are gathered. After stunning one with a sustained phaser shot, he places it in a specimen container with a pair of tongs and returns it to the ship.
McCoy analyses the creature, discovering that it is just a single-celled organism of enormous size, and that it seems to be part of a larger entity that exists in separate parts. McCoy then tries to determine what can kill the creature which seems to be immune to both heat and radiation. Kirk remembers the suicide pilot that flew into the sun, and suggests that the creatures may be sensitive to intense visible light, if the heat and radiation don't harm them. McCoy sets up a "light booth" and puts the specimen in it and the creature quickly dies.
Spock suggests the light may affect the alien tissue on his nerves as well, and volunteers himself put it to the test. McCoy exposes him to the same light which successfully kills the tissue. Unfortunately, since Spock refused eye protection (because the colonists themselves will not be protected), he is rendered blind. Testing the results, McCoy is mortified to discover that the ultraviolet light is all that was needed - the visible component that blinded Spock should not have been used at all. The Enterprise then launches over 200 specially fabricated ultraviolet flare satellites that bathe the planet Deneva with UV radiation, thus killing off all the parasites and curing all the people.
Soon afterward, Spock recovers his eyesight. An amazed McCoy says he should have been blinded permanently. Spock attributes the recovery to his set of Vulcan inner eyelids, which his people use to protect their eyes from the harsh sun on their planet.