The Daemons were an advanced race of beings who liked to experiment with the development of lesser races to see where they would lead. Millions of years in the past Earth became one of their subjects, but a problem led to Azal being marooned on the planet and putting himself into suspended animation. Using information from stolen Time Lord files, the Master found and used to the psychic energy of a local coven to 'summon' Azal, who decided that the experiment on Earth had failed, and he would either destroy it or hand it over to another - i.e. The Master himself.
However, Azal concluded that the Doctor was a better candidate, but upon his refusal, granted it to the Master after all. The Master orders the Doctor to be destroyed, but the Daemon was then unable to reconcile what it considered to be an illogical act in Jo Grant being willing to sacrifice herself instead of the Doctor, causing it to self-destruct (resulting in the destruction of the local church in Devil's End).