Justices voted 6-1 against the once hugely popular president, who is imprisoned on a corruption conviction he claims is a sham.
Da Silva's left-leaning Workers' Party issued a statement vowing to appeal, but there appeared to be little chance it would succeed.
That would seem to leave the party's fortunes in the hands of its current vice-presidential candidate Fernando Haddad, a former Sao Paulo mayor who so far has polled in single digits.
Supreme Court Justice Luis Roberto Barroso cast the first vote against da Silva, saying the ruling was "very simple" because the law forbids candidates whose conviction has been upheld on appeal.
"There is no margin here for the electoral court to make any other evaluation but the one showing there is a conviction, and that conviction matters in the candidate's eligibility," Mr Barroso said.
Justice Edson Fachin disagreed, citing a recent call by a UN human rights committee calling for da Silva to be allowed to run while he further appeals his conviction.
Even as the justices were debating, the Workers' Party put out ads on social media channels featuring da Silva, maintaining a strategy to keep the former president front and centre for as long as possible.
The former firebrand union leader led Brazil during a booming period from 2003 and 2010, promoting social policies that pulled millions from poverty. Then-US president Barack Obama once called him the "most popular politician on earth".
But da Silva and his party have lost much of that appeal over the last several years due to a stumbling economy under his hand-picked successor Dilma Rousseff and a sprawling corruption probe that has ensnared many top businessmen and politicians, including da Silva.
The 72-year-old ex-president is serving a 12-year-sentence for corruption and money laundering after being convicted of trading favours with construction company Grupo OAS in exchange for the promise of a beach house apartment.
Justice Barroso said the Workers' Party should replace da Silva within 10 days, and that he should not appear as a presidential candidate in free airtime that is given to political parties on nationwide TV and radio starting on Saturday.
In a statement late on Friday, the Workers' Party said it would appeal the electoral court ruling, just as da Silva is fighting to overturn his corruption conviction.
With da Silva out of the race, Mr Haddad was expected to take his place on the Workers' Party ticket. Polls show tepid support for his bid, but the party hopes da Silva's popularity could boost the former mayor's hopes.
On Saturday, Mr Haddad was scheduled to visit Garanhuns, a city in Brazil's impoverished North-East where da Silva was born.
Register for free to continue reading
Registration is a free and easy way to support our truly independent journalism
By registering, you will also enjoy limited access to Premium articles, exclusive newsletters, commenting, and virtual events with our leading journalists
Already have an account? sign in
Join our new commenting forum
Join thought-provoking conversations, follow other Independent readers and see their replies