Brazil's Workers' Party (PT) has formally registered jailed former President Luis Inácio Lula da Silva as its presidential candidate.
Supporters chanted "Lula for President" and "Free Lula" as they followed PT members to the electoral court in Brasilia hours before the deadline.
But the prosecutor general immediately filed to invalidate his candidacy, as his conviction was upheld in January.
In Brazil, no one convicted of a crime upheld on appeal can run for office.
That law would rule Lula out from running for the presidency in October. However, exceptions have been made to the law before.
Lula is currently serving a 12-year jail term for accepting a bribe.
He was convicted of receiving a renovated beachfront apartment worth some 3.7m reais ($1.1m; £790,000) as a bribe by engineering firm OAS.
He denied wrongdoing and said his conviction was part of a plot to prevent him returning to power.
The former president is the most high-profile person convicted in the sweeping Operation Car Wash anti-corruption investigation.
Police say 10,000 people took part in the march to the Brasilia court house.
Despite his jail sentence, the PT voted to nominate Lula as its candidate earlier this month.
Lula has reportedly chosen Fernando Haddad, former mayor of São Paulo, to run for the PT when he is likely prevented from doing so.
Serving as president from 2003 to 2011, Lula presided over a surge in economic growth and major social programmes that left him with an 87% approval rating on leaving office.
But the former leader surrendered to police in April after his corruption conviction.
An appeal in January not only saw the court uphold his original conviction, but also increase the length of the sentence by two-and-a-half years.
While the ex-president is still waiting for a final court judgement on whether he can run, Brazil's prosecutor general filed to bar his candidacy due to the law prohibiting those who have lost appeals against their conviction from standing.
Despite this, polls reportedly show around one third of Brazilians would back Lula if he were allowed to run, which would make him the front-runner in October's vote.