Egyptian leader Abdel Fattah al-Sisi on Wednesday formally submitted his candidacy for presidential elections in March that he looks certain to dominate as a string of potential challengers have dropped out.
Ali was the last significant figure known to be planning to run.
The case was pursued "for nothing except to provide a legal excuse that would prevent us from running", he said.
According to the military regulations, Anan has to resign or get prior approval from the supreme council of the armed forces before running for president; otherwise he could be summoned for military service whenever necessary.
"People's confidence that this election can be transformed into an opportunity to have a new start has, in my view, regrettably ended", he said.
Anan was detained as he drove through the Nasr City neighborhood of Cairo, his son Samir said by telephone.
There were, he said, "signs that pointed to a will to poison the whole operation and to corrupt and empty it of its supposedly democratic content".
Ali's candidacy was already at risk.
In his declaration of his intention to run in the upcoming elections, Anan said he wished to steer Egypt away from "wrong policies" that the current regime has adopted.
If that ruling was to be upheld on appeal, he would have been ineligible to run.
The last significant challenger remaining in the race, the leftist lawyer Khaled Ali, will be disqualified if he fails to overturn a criminal conviction for public indecency on March 7.
Annan's campaign is in the process of collecting 25,000 signatures, or "recommendations", from voters so that he could meet a constitutional requirement to run.
Abou Shaqa was appointed his legal representative, as well as the official spokesmen of the campaign, said the president on his official Facebook page.
With those candidates gone, Mr. Sisi's greatest challenge in the first round of voting, scheduled for March 26 to 28, may be to muster a convincing turnout.
A statement by the campaign of former military chief of staff and presidential hopeful Sami Annan says it is suspending its activity indefinitely following a statement by the armed forces listing an array of serious allegations against him. "Several members of our campaign were arrested", he said.
Earlier, Egyptian authorities stormed the homes of Anan's presidential campaigners and arrested a number of them. Under el-Sissi, links to the Brotherhood are grounds for prosecution.
"This is consistent with the Egyptian government's ongoing efforts to crush dissent and consolidate power by attacking civil society, activists and human rights defenders in the country".
In 2013, Sisi helped orchestrate the overthrow of the country's elected Islamist president, Mohammed Morsi, and was elected president the following year. "No one (should) make us go astray", he said.