Out of humility, he refused the position, presumably with the standard Latin phrase nolo episcopari, "I do not wish to be made bishop." (It is traditional that the candidate say this at least twice when offered a bishopric before finally accepting; if he says it a third time, he really means to refuse the promotion.)
Unfortunately for him, some people decided to malign him, spreading rumors that turned the populace against him and so unnerved him that he started spending all his energy in combatting the four rumors being spread, and attempting to find the sources of the rumors. The current bishop, hearing the rumors against him, fired him from his archdeacon position.
Finally, Theophilus appealed to a necromancer for help, who led him to a crossroads in the dark of the night and conjured up Satan. Satan offered a deal: in exchange for his soul, all calumnies against him would disappear. Theophilus agreed, and signed a contract with his own blood. The next day, he was summoned to the bishop's presence; the bishop had discovered that the rumors were false, Theophilus was a good man after all, and the bishop re-instated him in his position.
But Theophilus had no peace of mind. He paced his room night after night, regretting the foul bargain he had made, and he prayed. He undertook a fast of 40 days, praying every night, all night, until the 40th day when the Virgin Mary appeared to him. She rebuked him for his poor decision, and he asked her to intercede for him. This she agreed to do, and the following night she appeared in his dream and told him that her son had forgiven him. When he woke up the next morning, the static contract was with him.
That day being Sunday, he went to church, threw himself at the feet of the bishop to make his confession, and showed the congregation the contract. They destroyed the contract, Theophilus went home feeling unburdened...and died three days later.
People love a comeback story, and sinners repenting. Theophilus became the subject of poems and plays as well as sermons. The earliest version of the story claims to come from Eutychianus, a disciple of Theophilus who was an eyewitness. (The only Eutychianus who makes it into Christian records is a 3rd-century pope.) Legend tells us that Theophilus died in 538CE. There is a Latin version of the story (the original is Greek) from Paulus Diaconus.
It is in the 11th century that art depicting his story first appears, in carvings, but it really takes off in the 13th century in stained glass windows and illuminations. Above is supposed to be Theophilus building a church in his capacity as archdeacon. The usual portrayal is in four panes: signing the contract, Theophilus repenting, the Virgin recovering the contract from the devil, the Virgin returning the contract to Theophilus. Other than the Theophilus story, all examples of Marian art in churches and cathedrals are Bible stories.
One of the better-known composers of Theophilus-based poetry was Hrotsvitha of Gandersheim, a name that is so familiar to me that I'm shocked to find that I have never mentioned her before in this forum. I aim to correct that defect tomorrow.