Sagami-ji is a Shingon Buddhist temple in Kasai City, Hyogo Prefecture, Japan. It was built by Emperor Shomu in 745 at the request of Gyoki, a Buddhist priest.. The temple records tell us Gyoki received an oracle from Sagami Myojin instructing a temple to be built on these grounds. After the building was badly damaged in the Heiji Rebellion of 1159, it was rebuilt. The temple was again burnt down in conflicts during 1578.