Lord Chief Justice Woolf upheld a previous ruling that the man's 15-month detention at Belmarsh prison in south-east London is unjustified.
The Special Immigration Appeals Commission refused Mr Blunkett the right to appeal against the decision.
A court had already ruled the man should be freed, but his release was put on hold while the government was given time to mount a challenge to the decision at the Court of Appeal.
Some of the appeal hearing was held in private on the grounds of national security.
Wyn Williams QC, for the home secretary, said in open court Siac had accepted M was a member of an extremist Islamic movement in Libya and had fought with fellow Mujahedeen soldiers in Afghanistan.
It had also accepted the man had been involved in procuring arms to attack Colonel Gadaffi's regime and had transferred money to an individual suspected of having links with al-Qaeda.
Ben Emmerson QC, representing M, said Siac had found the assessments of M on which the Home Secretary had relied were not supported by evidence.
M was the first of 13 people to be detained under the Anti-terrorism, Crime and Security Act in November 2002.
The act allows the government to hold foreign nationals suspected of terror links but who cannot be deported, without charge or trial.
He is the first terror suspect to have appealed successfully against his imprisonment.