BRASILIA, Nov 7 (Reuters) - Brazil's Supreme Court decided on Thursday to end the mandatory imprisonment of convicted criminals after they lose their first appeal, a politically charged ruling that may lead to the release of former leftist President Luiz Inacio Lula da Silva.The reinterpretation of Brazil's penal code, allowing convicts to exhaust their appeal options before being locked up, could benefit dozens of high-profile prisoners, among them Lula, jailed last year for taking bribes.By a 6-5 vote, the court overturned a three-year-old rule that contributed to the success of Brazil's biggest corruption investigation, the so-called Car Wash operation that put dozens of company executives and politicians in jail for bribes and kickbacks.The prospect of serving immediate prison time after losing a first appeal encouraged suspects to negotiate plea deals with prosecutors, providing them information that helped unravel the biggest graft scheme in Brazil's history.The Car Wash prosecutors said the ruling would make their job harder and favor impunity because of Brazil's "excessive" appeal processes. They said in a statement that the court's decision was out of sync with a country that wants an end to corruption.Lula's lawyers said they would seek his immediate release by the lower court that convicted him. He was jailed in 2018 for eight years and 10 months after he was found guilty of taking bribes from engineering firms in return for government contracts.Chief Justice Jose Antonio Dias Toffoli, who cast the deciding vote, said releases would not be automatic but decided by courts on a case-by-case basis.POLARIZED COUNTRYLula, 74, governed Brazil from 2003 to 2010, its first working-class president. He left office with sky-high popularity ratings thanks to social policies that raised millions from poverty, but his critics say he ruined the country by allowing corruption to flourish.Lula's release would heighten tensions in a polarized nation that elected far-right President Jair Bolsonaro last year. Lula had been favored to win the 2018 election but his imprisonment barred him from running.If and when he is released, Lula would be free to engage in politics but would not be eligible under Brazil's Clean Record law to seek elected office for eight years after his first conviction in June 2017.His Workers Party welcomed the court's decision. Its leader, Gleisi Hoffmann, called it "a very important step to strengthen democracy and the Constitution at a time when they are under threat from an extreme-right government."Sergio Moro, the Car Wash trials judge who sentenced Lula and is now justice minister in Bolsonaro's government, warned before the court's decision that overturning the rule would be a big setback for the fight against corruption.According to the National Council of Justice, some 4,895 convicts could potentially benefit from the rule change.The Brazilian Bar Association argued that the mandatory prison rule violated the constitution by not respecting the presumption of innocence of defendants throughout the appeals process.Anti-corruption movement Vem Pra Rua, or 'Take to the Streets,' had published full-page ads in newspapers saying a decision to overturn the rule would be a terrible setback."We fear Brazil will become known as the country of impunity," the group said. It announced protests in Brazilian cities on Saturday.