BRASILIA (Reuters) - Brazil’s jailed former president Luiz Inácio Lula da Silva is preparing to give up his bid to run in next month’s presidential election, three party sources said, after he lost two appeals at the Supreme Court on Thursday.

Slideshow ( 3 images )

That will remove the most popular candidate from October’s race and pave the way for Lula’s hand-chosen successor, Fernando Haddad, to become the Workers Party (PT) candidate.

Justice Edson Fachin ruled against a request from Lula’s legal team that argued that Brazil was required to follow the recommendation of the United Nations Human Rights Committee and allow Lula to run for office from jail. Lula’s legal team appealed the ruling.

Later in the day, Justice Celso de Mello rejected a separate, similar motion to maintain Lula’s candidacy, court documents seen by Reuters showed.

The PT sources said that Lula is expected to hand over a letter to Haddad during a jail cell meeting between the two men on Monday.

In the letter, Lula, who remains by far Brazil’s most popular politician, will ask his followers to vote for Haddad, the sources said. The PT has until the end of Tuesday to register Haddad as its presidential candidate.

Lula, who served as president from 2003-2010, is ineligible for office under Brazil’s “Clean Slate” law, which prohibits candidates from running if they have convictions that have been upheld on appeal.

Despite his conviction and several graft cases pending against him, Lula leads the electoral race by a long stretch, with 39 percent of voter support, according to pollster Datafolha. Lula has denied any wrongdoing.

His nearest rival, far-right candidate Jair Bolsonaro, has 19 percent. Bolsonaro was in hospital in serious condition on Thursday after being stabbed while out campaigning.

With his appeals failing and time running out for the PT to register a candidate, the reluctant Lula finally decided that it was time to give up his fight to run, the sources said.

Polling has shown that Haddad, who is mired in single digits, would get a huge boost if backed by Lula to run, possibly enough to propel him into a second-round runoff. However, Haddad’s chances were dealt a blow on Tuesday when he was charged with corruption, accusations that he denies.

The chance that the leftist PT could return to power has spooked markets, helping send Brazil’s currency near historic lows.