Court documents show that Uzbek national Rakhmat Akilov asked his state-appointed lawyer, Johan Eriksson, to "relieve himself of his mission".
The 39-year-old said that he "expressly wanted to be represented by a Sunni Muslim" and that "only a lawyer of this faith could assert his interests in the best way".
But the judge dismissed the request "for lack of sufficient reasoning", according to the documents.
Akilov admits to carrying out a terror offence, Eriksson told Stockholm District Court on Tuesday.
The court then ruled that Akilov should be placed in pre-trial custody.