ANTANANARIVO, Madagascar — Two former presidents of Madagascar are neck and neck as votes are being counted in the presidential election that seeks to end years of political instability in this Indian Ocean island nation.

According to partial results announced by the National Electoral Commission on Thursday, Andry Rajoelina had 45 percent of votes counted and Marc Ravalomanana had 40 percent, with results from 291 of the more than 24,000 polling stations.

The electoral commission said that about 48 percent of the 9.9 million registered voters cast their ballots in the election.

Rajoelina was appointed by the military to be president during the transitional period from 2009 to 2013 and Ravalomanana was president from 2002 to 2009. The former presidents waged assertive campaigns among the field of 36 candidates in the presidential election.