COLOMBO, Sri Lanka—In the five years since Sri Lankan President Mahinda Rajapaksa’s government crushed a long-running separatist insurgency, he has worked methodically to cement his, and his family’s, control of the country’s politics.

Now, as Sri Lankans head to the polls Thursday, the structure of the government hangs in the balance. His opponent—part of a rebellion among some of the president’s once-closest allies—is mounting an unexpectedly strong challenge to Mr. Rajapaksa’s re-election with a pledge to strip the Sri...