M'hanit

Living comet worshipped by the Shepherds

A massive comet regarded as alive and sacred by its alien guardians, whose course the Enterprise changed to save an inhabited world.

M'hanit appeared to be a comet but carried strange structures and responded to contact in ways that suggested it was alive or at least aware. Aliens known as the Shepherds guarded it and treated it as sacred, believing its path should never be changed.
In Children of the Comet, the comet was on course to strike an inhabited planet. The Shepherds' ship blocked the Enterprise's attempts to divert it. Nyota Uhura found the comet responded to music and decoded a message showing it had expected their interference. While the Enterprise distracted the Shepherds, Spock nudged the comet off course, and as it passed the planet it released water vapor that improved conditions for life there.