This paper explores the relationship between the Koxinga Shrine and the local society of Tainan from the 16th century to the present through the analysis of the temple's founding legends, the change in the Konxinga Shrine's belief and the evolution of its worship rituals. The author argues that there were at least three divergent deities sacrificed in the Temple of the Founding King, that was, the predecessor of current Shrine, including a nebulous cult of Wang-Yie, a military officer in the Sui dynasty and Koxinga in the Ming-Qing transition. Since these deities were created and supported by different groups and along with the conversion of this temple from a local cult to an official worshipping space since late Qing, local gentry members of the Tainan city showed their familiarity with the state rituals and played the crucial role in the transformation process. The traditional festivals and organizations of the original Temple of Founding King are maintained in the façade of the official temple, and they provide the locals with credible historical resources to negotiate with the state in the social and political circumstances nowadays.