Mahinda Rajapaksa, once poised to be Sri Lanka's president for life, is a desperate man these days. At stake is not just his own political future, but that of an entire dynasty and a network of supporters he founded at every level.

A shocking loss to a former ally in the January election he had himself called two years ahead of schedule has hit his once powerful family's fortunes hard. It seems only a political revival may offer them some hope of protection from the slew of corruption and other criminal charges they now face.

So Rajapaksa is in the race in this month's election for prime minister, a job only second to that of president.

While in power, he created a powerful narrative of the warrior king and the savior of his people who led a successful military campaign against separatist Tamil Tiger rebels to end a decades-long civil war. He also abolished the two-term limit for presidency, enabling him to stay in power for life or until his eldest son, who he was grooming, was ready to take over.

And he consolidated all power among a tight coterie of friends, family and loyalists, taking control of the Parliament, courts and all state institutions.

The electoral upset to his former health minister, Maithripala Sirisena, changed all that.

Now several members of Rajapaksa's inner circle are under investigation for graft, murder and abuse of power. They have denied the allegations.

While Rajapaksa himself is being investigated on a relatively minor allegation of appointing a minister during an election, which authorities say amounts to bribery, the government is still trying with the help of international agencies to locate his allegedly ill-gotten wealth — which could lead to more serious charges.

Soon after his defeat, Rajapaksa's once-powerful brothers also lost their positions. Basil Rajapaksa, the former economic affairs minister, was arrested and charged with misusing state funds for election purposes. He has been released on bail.

Another brother, Gotabhaya Rajapaksa, the influential former defense secretary, is under investigation after a former ally accused him of abducting journalists, critics and Tamil rebel suspects. There are only a few survivors of enforced disappearances known as the "white van abductions."

Rajapaksa's all-out campaign to return to power is seen as a desperate attempt to stay politically alive and to stem the damage and likely criminal prosecution that his loyalists and potentially himself face.

"The decision to re-enter politics and contest a parliamentary seat raises a question about his decency, and on the other hand it seems as an attempt to safeguard his family and his close associates who are facing various allegations from the long arm of the law," said Terrance Purasinghe, a political scientist.

His return to the political forefront after a humiliating defeat is also a testament to his tenacity.

"Politics is part of his body and blood," said Jehan Perera an analyst with National Peace Council, a local activist group. "His value comes from the powers he has. ... He is a fighter who never gives up."

Rajapaksa started laying the groundwork for his comeback soon after his defeat, organizing meetings with supporters and attending religious ceremonies at Buddhist temples, which turned into mini campaign rallies and received wide media coverage.

He has managed to retain the loyalty of many members of the United People's Freedom Alliance coalition, which compelled an unwilling Sirisena to nominate Rajapaksa for prime minister.

To his loyalists, many of whom are mired in allegations of drug dealing, corruption, and murder, Rajapaksa is the one name they can recall for their own re-election to Parliament and safety from prosecution by using their influence to manipulate the system.

Rajapaksa acknowledged his failings in letting his coterie run amok. He didn't get into specifics in his speeches, but he was accused of manipulating the justice system to protect a lawmaker accused of killing one of his own advisers. He was also accused of not taking action against politicians accused of rape and drug dealing.

"That's a big mistake. I apologize to you and I will not repeat them," he said at one temple meeting.

Even though he cleared the first hurdle and won his party's nomination, the odds are still stacked against him.

Apart from the erosion of his own vote base, Sirisena has come to his side very grudgingly and a section of Rajapaksa's own party doesn't back him.

"I have no dealings with Mahinda Rajapaksa, I have the same criticism for him that I had before Jan. 8," Sirisena said in a speech last month. He said that with Rajapaksa, the party would not attract votes from minority Tamil and Muslim communities or the youth.

After the victory against the Tamil Tigers, Rajapaksa had projected himself as protector of the majority Sinhala-Buddhists and seen as slacking in post-war reconciliation. He was also accused of secretly supporting Buddhist nationalist groups that carried out attacks against Muslims, destroying mosques, property and in one major riot killing three Muslims.

Sirisena has indicated that his personal preference would be to form a government with Rajapaksa's rival and current Prime Minister Ranil Wickremesinghe. Sirisena and Wickremesinghe were part of a grand opposition coalition that unseated Rajapaksa. After his victory, Sirisena was invited back to the UPFA to become its leader.

With less than two weeks before the election, Rajapaksa is trailing Wickremesinghe according to a latest opinion poll.

The survey by independent think tank Center for Policy Alternatives questioned 1,986 people from across the country and ethnic groups, and shows that Rajapaksa has the support of 27.5 percent against 39.8 percent for Wickremesinghe. The survey had a 2-percentage point margin of error.

If he cannot close that gap by Aug. 17, Rajapaksa stands to lose his political career.

"I think he will be isolated and marginalized. He will be a spent force," Perera said.

____

Associated Press writer Bharatha Mallawarachi contributed to this report.