Judge Ivan Athié of the TRF-2 federal appeals court said in his ruling that the evidence provided by investigators did not justify the "preventive" jailing of Temer and seven other defendants, including former minister Wellington Moreira Franco.
Police have been investigating Temer for allegedly taking bribes in return for helping shape a decree regulating Brazil's ports, and in particular for extending concessions in the port of Santos to benefit companies of close associates.
The request relates to an investigation into whether Temer accepted bribes in exchange for extending a concession last year for operating services in the Port of Santos, Latin America's busiest container port.
Brazil's lower house of Congress voted on Wednesday to reject a corruption charge against President Michel Temer for allegedly taking bribes, saving him from facing a possible Supreme Court trial that could have ousted him from office.
In a separate investigation, prosecutors cite a secretly recorded late-night meeting between Temer and one of JBS's owners, Joesley Batista. In the recording, Temer allegedly is heard authorizing hush money payments to senior politician Eduardo Cunha.