The writ of mandamus is a procedural instrument provided for in the Federal Constitution to protect citizens against abuse of power or illegality committed by a member of the Public Administration. With this constitutional lawsuit, the aim is to re-establish the legal situation and protect the right of the covered person arbitrarily restricted by an authority.
Faced with so many peculiarities in the handling of the writ of mandamus, there is an important point about whether it is possible to withdraw it at any time, especially after the trial denying the order has been issued and regardless of the agreement of the administrative authority.
Law 12,016/09, which establishes the framework of the writ of mandamus, does not address the issue, such that the provisions of the Code of Civil Procedure (CPC) are applicable to the matter.
First of all, it is worth making a distinction between withdrawal and waiver. Withdrawal produces eminently procedural effects, whereas waiver, precisely because it is closely related to the substantive right itself under discussion in the case, receives separate treatment.
If the party in a procedural relationship chooses to withdraw the claim, the effect of this unilateral act is extinguishment of the suit without a resolution of the merits, as provided for in article 485, subsection VIII, of the CPC. This is because, regardless of the reason that led the party to withdraw from the proceeding, such conduct takes on a procedural form, causing only the case itself to cease. That is, there is repercussion only in the procedural field. The substantive right remains intact. In other words, the existing discussion will not be able to affect the underlying substantive right for any purpose. Thus, it is permitted for a private party to file a new lawsuit - writ of mandamus or any other type compatible with the claim made - provided that it is within the deadline for the exercise thereof.
On the other hand, with waiver, the effects arising from such an expression of will affect the underlying substantive right and the party which has granted it recognizes the right of the counterparty, including with retroactive effect. So much so that a trial ratifying the waiver expressed by the party resolves the merits of the case and is equivalent to acceptance of the opposing party's claim. This is the provision of article 487, subsection III, letter 'c' of the CPC.
Faced with the effects that these unilateral statements propagate, the CPC does not contain any provision to condition a trial that resolves the merits (in the event of waiver) with the agreement of the opposing party. On the other hand, paragraph 5 of article 485 of the CPC provides that the withdrawal of the lawsuit may be filed up to the trial. This led to the understanding that, after this decision was issued, its ratification would be conditional on the agreement of the opposing party.
However, in the case of an application for mandamus, unlike in actions involving only private parties, the authority's agreement to the request for withdrawal is dispensable. This is because, while in private relations (fully governed by the CPC) the defendant also has an interest in judicial relief from the moment it joins the case, in disputes against the Public Administration, via the route of mandamus, there is nothing to be said of the State's interest in obtaining a decision that recognizes the legality of the contested act.
In fact, the acts performed by the Public Administration are considered, even if by presumption, in line with the legal system until another one (administrative act or judicial decision) comes about that says otherwise. Therefore, from the Public Administration's perspective, before or after the trial in a writ of mandamus, there is not even a procedural interest that requires ratification of the withdrawal with the agreement of the authority.
Due to the characteristic of self-execution of administrative acts, it is not necessary for the Judiciary to act with the objective of recognizing the existence of a right against the private party. The Administration is allowed to adopt measures for direct execution of its own act. As an example, tax foreclosures.
The matter was examined by the Federal Supreme Court (STF), under the general repercussion system, in the trial of Extraordinary Appeal 669.367-RJ, in which the Court decided that the provision of the Code of Civil Procedure of 1973 (article 267, paragraph 4 - reproduced in article 485, paragraph 5, of CPC/2015) which required the agreement of the adverse party for ratification of the withdrawal after the trial was rendered is not applicable to writs of mandamus.
According to Justice Rosa Weber, who issued the prevailing opinion, even if the trial has granted the mandamus claimed, "by withdrawing from favorable judicial relief in a writ, the applicant is subject to the prevalence of the administrative act that, before, it sought to rule out, as though the writ had never been filed; the self-execution of the administrative act resurfaces in its entirety.”
Necessarily, with the withdrawal in a writ of mandamus manifested after the trial has been rendered - whether it was favorable for or against the private party - the effect is to restore the enforceability of the administrative act challenged in the proceedings. Even in situations where the trial is unfavorable to the private party, the withdrawal from the writ of mandamus will only entail preservation of the act of authority as issued, there being no grounds for objection by the Public Administration.
In the case of a writ of mandamus, it is not in the interest of the Public Administration to obtain a judicial enforcement instrument (res judicata) to protect itself from the taxpayer. The administrative act fought is already endowed with self-execution. With the withdrawal of the claim, its legality is confirmed.
The elements outlined contribute to conclude for the correctness of the position reached by the STF, followed by the Brazilian courts, and on the need to interpret the rules that establish the procedure in line with the particularities of the substantive law discussed in the specific lawsuit.
The withdrawal from the writ of mandamus, regardless of the stage of the proceeding, re-establishes the self-execution of the administrative act contested. Therefore, the requirement that the authority agree to the private party's claim is unnecessary, since the end sought by the Public Administration itself will already be achieved.
 Article 485. The judge shall not decide the merits when he: (...)VIII - ratifies withdrawal of the action;
 Article 487. There shall be a resolution on the merits when the judge: (...) III - ratifies: (...) c) the waiver of the claim made in the action or in the counterclaim.