『続日本紀』や『宀一山年分度者奏状』(べんいちさんねんぶんどしゃそうじょう)によると、奈良時代末期の宝亀年間(770年-781年)、時の東宮・山部親王(のちの桓武天皇)の病気平癒のため、室生の地において延寿の法を修したところ、竜神の力でみごとに回復したので、興福寺の僧・賢璟(けんきょう)が朝廷の命でここに寺院を造ることになったという。
"Shoku Nihongi" (Chronicle of Japan Continued) and "Benichisan nenbundosha sojo" say that in the late Nara period (770-781), a ceremony to cure the disease of the crown prince, Imperial Prince Yamanobe (later Emperor Kanmu), was held in Muro, after which he recovered thanks to the power of the dragon god, so Imperial Court ordered a priest of Kofuku-ji Temple: Kenkyo to build a temple on the site. - Wikipedia日英京都関連文書対訳コーパス