Larry Brody had originally sent his script for the third season of the original series Star Trek (1966) but producer Fred Freiberger rejected it. Three years later, he pitched the same idea to Gene Roddenberry for this series. Roddenberry loved the idea and Brody's script, but according to Brody,, Roddenberry rewrote the entire script. Brody did not realize this until the episode aired.
In the original script, the crew meet God. NBC objected to any reference to God. The producers changed God to the Devil and NBC accepted it. In Star Trek V: The Final Frontier (1989), Star Trek was finally able to make a "Captain Kirk meets God" story.
This is the only episode of the series to feature Earth.
The Magicks of Megas-Tu was originally broadcast on NBC on Saturday October 27, 1973. When it was re-aired the following spring, all references to Lucien actually being Lucifer had been edited out. Whether this was at the insistence of the network, sponsors, or others is not known. The removal of this critical plot point detracted much from the rebroadcast.
A later take on this story's scenario, where the Enterprise crew meet a powerful person who appears to be The Devil, was written as a treatment for the never-produced series Star Trek: Phase II around 1978. After a series of heavy re-writes over the years, it was finally given form in Devil's Due (1991) with Picard's crew from the Enterprise-D.