BOA VISTA, Brazil — Brazil’s top court ruled early Thursday that former President Luiz Inácio Lula da Silva can be sent to prison while he continues to appeal his corruption conviction — an explosive decision that upends the nation’s politics and appears to quash his bid to return to power.

There was more at stake than the legal fate of Mr. da Silva, 72, a towering and divisive figure in Brazilian politics who has a considerable lead in the polls for October’s presidential election.

The 6-to-5 ruling against the former president, who has called his prosecution an underhanded ploy to keep him off the ballot, is likely to call into question the legitimacy of the election in the eyes of many Brazilians.

“No matter how many roses the mighty kill, they will never manage to stop spring,” Mr. da Silva’s Workers’ Party said in a statement posted on Twitter after his fate became clear.