Modi was accompanied by Telugu Desam President president N Chandrababu Naidu.
Janasena founder, Pawan Kalyan, actor-turned-politician and brother of Union Minister Chiranjeevi, was also with the two leaders at the temple.
Temple sources said that they were in the temple for about 20 minutes.
Before leaving the shrine, temple priests, amid chanting of vedic hymns, invoked divine blessings on Modi.
After offering worship on the hills, the trio also offered prayers at the shrine of Lord Shiva called Vaayulingeswara at Sri Kalahasti, 40 km from Tirupati.
Later they flew to Madanapalli, 100 km from Tirupati, to address a public meeting.
Police had made tight security arrangements for the visit.
Kicking off his two-day campaign in the region of residuary Andhra Pradesh, Modi, sharing the dais with Naidu and Pawan, addressed a public meeting on Monday night.
BJP sources said during his month-long campaigning across the country, Modi has also visited the famous shrines of Lord Vishwanath at Kashi and Lord Jagannath in Puri.
Snap, chop, skin alive... Telangana's rude poll speak
'New govt should be cautious of ill-advised decisions'
PIX: Stakes high as crucial Phase 7 of LS polls underway
The city of 1.637 million Modis
What's happening in India's biggest constituency?