Mr. Rajapaksa, who was first elected in 2005, has shown a rapt interest in what astrologers are saying about him. In 2009, an astrologer named Chandrasiri Bandara, who wrote a column for a pro-opposition weekly, was arrested and questioned by the Criminal Investigations Department after he predicted that Mr. Rajapaksa might be ousted. Mr. Bandara was released shortly afterward, and he continues to comment on politics, but with considerably more caution.

State television recently showed clips in which Mr. Bandara offered the opinion that recent torrential rains had been unleashed by Mr. Sirisena’s betrayal. In an interview, he smilingly declined to say which candidate, Mr. Rajapaksa or Mr. Sirisena, had submitted his nomination papers at a more auspicious time.

“If I saw which one is better,” he said, “I’ll have to go again in a white van.”

Astrology is part of daily life all over South Asia, where many people believe they are influenced by the movement of the planets starting at the moment of their birth. H. L. Seneviratne, a professor emeritus of anthropology at the University of Virginia, recalled a friend in Sri Lanka who made a distinguished career in the law, but never once left home except at the “magically correct time.” Like the population, nearly all the country’s leaders have been ardent believers, he said, with a few standouts, like Mr. Premadasa, who seemed especially desperate for protection.

“There is a theory that the fishermen who go fishing in the lagoons do not use magic, but the fishermen who go fishing in the sea, they are full of magic,” Mr. Seneviratne said. “There is so much anxiety, and to cope with it, there is magic.”

Mr. Abeygunawardena’s office is decorated with life-size photographs of himself with the president and a giant framed copy of his own Wikipedia entry. One celebrity pictured is Mr. Sirisena, who denounced the president in November and is running against him. Asked about the defection, Mr. Abeygunawardena gave a small grimace of regret: He said he was close with Mr. Sirisena until he mysteriously stopped visiting a few months ago.

“I didn’t expect it and didn’t predict it,” he said of the defection, adding that Mr. Sirisena’s horoscope was not strong. “The planet Saturn is in his house, and it’s a bad time for him. A very bad time,” he said. “His house is clearly spoiled irreparably.”

Mr. Abeygunawardena forged his relationship with Mr. Rajapaksa in the 1980s, when he approached the politician with a prophecy. Mr. Abeygunawardena told him he was the long-awaited Prince Diyasena, the hero who, according to Sinhala Buddhist legend, was destined to save Sri Lanka from anarchy and then rule for around 24 years. These days, he said, he and the president speak almost daily, usually between 5 a.m. and 7 a.m., “even if he is at the gym, or doing yoga.”