Lula: Judge Sergio Moro had a political agenda
Brazil's former president, Luiz Inácio Lula da Silva, says he was jailed to prevent him from winning the 2018 presidential election which saw far-right candidate Jair Bolsonaro elected.
In an exclusive interview with the BBC via letters from his cell, Lula said Judge Sergio Moro "did politics and not justice" when he sentenced him.
Mr Moro says the verdict was upheld by an appeals court and was not "a one-man decision".
Lula is serving a 12-year sentence.
A month before the election, an electoral court banned Lula from running on the grounds that he had been sentenced, and that sentence had been upheld on appeal.
Beaten to the top job
At the time, Lula had a 20-percentage-point lead over his closest rival, Jair Bolsonaro, in opinion polls.
- Brazil's Lula: Saint or sinner?
- Jair Bolsonaro beyond the sound bites
- Jair Bolsonaro: Trump of the Tropics?
Lula's Workers' Party replaced him on the ballot with his running mate Fernando Haddad on 11 September.
With less than a month to campaign as presidential candidate, Mr Haddad struggled to match Lula's name recognition.
While he made it into the run-off, Mr Haddad lost to Mr Bolsonaro by 10 percentage points.
Banned from giving face-to-face or telephone interviews, Lula answered questions posed by Brazilian journalist Kennedy Alencar for a BBC TV documentary via letters.
In them, Lula said that "Bolsonaro only won because he did not run against me".
Lula was sentenced by Judge Moro to nine and a half years in prison after being found guilty of corruption in July 2017 over a scandal linked to oil-giant Petrobras.
In his letters, Lula argues that his guilty verdict was politically motivated.
"I was convicted for being the most successful president of the Republic [of Brazil] and the one who did most for the poor," he wrote, referring to his high approval rating when he left office after serving as president from January 2003 to January 2011.
"[Judge] Moro knew that if he acted according to the law he would have to acquit me and I would be elected president."
"So he did politics and not justice and now benefits from it," Lula wrote, referring to the nomination of Judge Moro to the post of justice minister by President-elect Bolsonaro.
The decision by Mr Moro to accept the post was heavily criticised by many in Brazil who had accused the judge of disproportionately targeting left-wing politicians in his anti-corruption drive.
It was also seen as an about-face by Mr Moro who had told Brazilian newspaper O Estado de S. Paulo in 2016 that he would never enter politics.
Mr Moro said that he was led to make the decision to become justice minister by "the prospect of implementing strong policies against corruption and organised crime, while respecting the constitution, the law and rights".
In his letters, Lula also insists on his innocence, writing that "I am imprisoned for no reason". He warns fellow Brazilians that their rights are under threat "if this can be done to a former president".
In response to Lula's allegations, Mr Moro said that the former president was convicted for being "the mastermind of [the] Petrobras scandal". "About $2bn were paid in bribes using Petrobras contracts during his presidency," he wrote in a message to Kennedy Alencar.
Mr Moro also pointed to the fact that an appeals court unanimously upheld Lula's conviction in January and increased the sentence to 12 years and one month, and the Superior Court in Brasilia had upheld his prison order.
"It is not a one-man decision," Mr Moro wrote of Lula's conviction.
He also added that his nomination as justice minister did "not have anything to do with [Lula's] conviction".
"I did not even know the elected president in 2017 when the sentence was delivered," he wrote.
Lula surrendered to police in April and has been held in a cell in at the federal police headquarters in Curitiba since.
The three-part BBC documentary series "What happened to Brazil..." will be broadcast on BBC World News starting on 12 January 2019.