A holy man from the north, Hathiram, plays dice every night at Tirumala with the god himself, who leaves a necklace behind one night. Accused of stealing it, Hathiram is shut in a room with a cartload of sugarcane he must eat by dawn, and an elephant eats it for him.
Hathiram came from the north around 1500, settled in an ashram near the temple and was such a devotee that the god came to play dice with him at night. One night in a hurry the god left a necklace behind. The priests, opening the temple, found an ornament gone; Hathiram, bringing it, said the god had left it. The matter reached Giridhara Raya, king of Chandragiri, who had the house filled with sugarcane and told Hathiram to eat it all by dawn, or die. Guards stood outside. Hathiram chanted the god's name and fell asleep, and a great white elephant appeared inside, ate every stick, and vanished. In the morning the king found the sugarcane gone and no elephant seen, and made Hathiram supervisor of the rituals. Hathi is elephant, and Ram the name he chanted.
In the version told among pilgrims, it is the priests who do not believe him. To shame him they lock him in a room with ten measures of cooked rice and ten bundles of sugarcane and say that if he is really as holy as he claims he will eat it all by daybreak. Within minutes the food is gone, and Hathiram kicks the locked doors to pieces and walks out trumpeting like an elephant. The scenes of the dice game are carved on the temple doors, and his matha stands opposite, with his samadhi.