After various efforts to exorcise the spirit(s) failed, Kameyama requested the help of Tōfuku-ji's Mukan Fumon.
With the ghost finally gone, in 1290 a grateful emperor gifted Mukan Fumon (無関普門 1212-91) the 'Upper Palace' (上の宮) of Zenrinji-dono.
Out of the existing buildings Mukan created Nanzen-in (南禅院), which would expand to become the great Zen temple of Nanzen-ji (南禅寺).