Gaya derives its name from the mythological demon Gayasur (which literally means Gaya the demon), demon (asur, a Sanskrit word) and Gaya. Lord Vishnu killed Gayasur, the holy demon by using the pressure of his foot over him.
This incident transformed Gayasur into the series of rocky hills that make up the landscape of the Gaya city.It is a legend that lord Vishnu promise to demon Gayasur that this city will be popular by the name of Great Demon Gaya sur. And who will perform shraddha (pinnddan) ceremonies on the foot print of lord Vishnu there ancestors will go to heaven and moksha.