Circumstances were against him, however, and the count of Castelmelhor, fearing his influence at court, had him exiled first to Porto and then to Coimbra; but in both these places he continued his work of preaching, and the reform of the Inquisition also occupied his attention. To silence him his enemies then denounced him to that tribunal, and he was cited to appear before the Holy Office at Coimbra to answer points smacking of heresy in his sermons, conversations and writings. He had believed in the prophecies of a 16th-century shoemaker poet, Bandarra, dealing with the coming of a ruler who would inaugurate an epoch of unparalleled prosperity for the church and for Portugal, these new prosperous times were to be called the Quinto Império or "Fifth Empire" (also called "Sebastianism"). In Vieira's famous opus, Clavis Prophetarum, he had endeavoured to prove the truth of his dreams from passages of Scripture. As he refused to submit, the Inquisitors kept him in prison from October 1665 to December 1667, and finally imposed a sentence which prohibited him from teaching, writing or preaching.