The Warlock In Spite Of Himself by Christopher Stasheff

A government agent with uncanny psionic abilities is sent to a backward, superstition-dominated world and adopts the persona of a warlock to protect settlers and investigate local witches; blending scientific trickery, espionage, romance and political intrigue, he must outwit feudal rulers and occultists while using ‘magic’ to introduce practical knowledge and survive in a society that fears technology.

Purchase from Bookshop.org