The use of rock-cut sanctuaries goes back to the time of Emperor Ashoka, during the third century b.c. , when itinerant Buddhist monks formed a religious order and the emperor provided them with rock-hewn cells as a vihara (retreat) during the monsoons.
Rock-hewn sanctuaries are a relatively new tradition in Buddhism, dating back to about the 12th century A.D.