A few hours after praying at the temple, Mr Rajapaksa, his family and members of the Sri Lankan delegation flew to Colombo amid tight security.
His two-day visit had been marred by protests by Tamil groups who denounced the president for not granting autonomy to Tamil areas and for human rights violations.
Mr Rajapaksa, his wife Shiranthi and other family members had a 'darshan' of the resident deity early on Saturday. They also took part in the 'Suprabhatha Seva', a pre-dawn ritual, temple officials said.
After visiting the temple, he told the media that India was a democratic country and everyone had a right to protest.
"What can I do" This is a democratic country," he said, when asked about his reaction the protests.
Asked about alleged right violations in Sri Lanka, he said: "come and see for yourself what is happening there."
The president left the temple for Renigunta airport in a motorcade amid tight security and took off for Colombo in a special aircraft.
The road from Tirumala Hills to the airport was closed for traffic. Security was beefed up along the route.
The president arrived in this temple town on Friday evening.
There were no protests in the temple town on Saturday unlike Friday when a large number of Tamil activists from neighbouring Tamil Nadu tried to stall Mr Rajapaksa's visit.
Earlier, priests offered 'prasadam' and the silk 'vastram' of the presiding deity to Rajapaksa. Temple officials also presented him a memento of the presiding deity.
Officials of Tirumala Tirupati Devasthanam (TTD), which manages the affairs of the famous temple, welcomed Mr Rajapaksa.
Though as a VIP he was entitled to the 'Mahadwaram' entry, he opted to enter the temple through the 'Vaikuntam' queue complex like a common devotee.
Mr Rajapaksa spent Friday night at TTD's Sri Padmavathi Guest House.