Iqbal sought to have the justices recognise an established pattern of mistreatment of and discrimination against Muslim detainees by administration officials under George Bush, the then US president, as they conducted the so-called "war on terror".
"It should come as no surprise that a legitimate policy directing law enforcement to arrest and detain individuals because of their suspected link to the attack would produce a disparate, incidental impact on Arab Muslims," Justice Anthony Kennedy wrote in the court opinion.
"Even though the purpose of the policy was to target neither Arab nor Muslims."
Iqbal argued that officials such as Mueller and Ashcroft were liable for the treatment handed out to prisoners even though they were not personally involved in the handling of detainees.
"We reject this argument," the court said in its opinion.
Kennedy said that there was insufficient evidence that Ashcroft and Mueller had deprived Iqbal of his constitutional rights.
In the weeks after the attacks on Washington DC and New York, US authorities detained 762 non-citizens, almost all Muslims or Arabs.
The US justice department's inspector general has found that many of them held at the federal prison in the New York district of Brookyn suffered abuse.
Ashcroft and Mueller argued they have qualified legal immunity because any misconduct was done by lower-level officials and they had no personal involvement in or knowledge of the alleged abuse.
The issue before the supreme court on Monday involved only whether Iqbal's lawsuit against the two senior officials could continue and did not address his claims of mistreatment against other lower-ranking current and former government officials.
Iqbal sued about 30 other current or former US government officials, including the warden at the detention facility and the director of the federal Bureau of prisons.
The ruling could be a blow to other former detainees and human rights groups that had hoped to bring cases against Bush-era officials.