
581 F.3d 1182 (2009)
Patrick F. CHIOINO, Petitioner-Appellee,
v.
Scott M. KERNAN, Warden, Respondent-Appellant.
No. 08-15265.
United States Court of Appeals, Ninth Circuit.
Submitted July 16, 2009.[*]
Filed September 21, 2009.
Edmund G. Brown, Jr., Attorney General for the State of California, Dane R. Gillette, Chief Assistant Attorney General, Gerard A. Engler, Senior Assistant Attorney General, Peggy S. Ruffra, Supervising Deputy Attorney General, and Jeffrey M. Laurence, Deputy Attorney General, San Francisco, CA, for the respondent-appellant.
Mary McNamara and August Gugelmann, Swanson, McNamara & Haller LLP, San Francisco, CA, for the petitioner-appellee.
Before: BARRY G. SILVERMAN, RICHARD R. CLIFTON and MILAN D. SMITH, JR., Circuit Judges.
MILAN D. SMITH, JR., Circuit Judge:
Patrick F. Chioino (Petitioner) is a California state prisoner who pleaded guilty to *1183 robbery and personal use of a firearm with a prior strike conviction, and was sentenced by a California trial court judge to an upper-term sentence with enhancements, totaling twenty-two years. The district court granted Petitioner's post-conviction petition for a writ of habeas corpus, finding that Petitioner's sentence should have been a middle-term sentence with enhancements, totaling eighteen years. Warden Scott M. Kernan (Respondent) appeals, arguing that the district court erred in reducing Petitioner's sentence itself instead of remanding to the California trial court for resentencing. We agree, and hold that the district judge's role in this habeas proceeding was solely to ensure that Petitioner's sentence was constitutionally determined, not to resentence Petitioner.

FACTUAL AND PROCEDURAL BACKGROUND
In this habeas action, Petitioner challenges the sentence imposed on him after he pleaded guilty to robbery and admitted the two sentence enhancements allegations that he (1) had one prior strike conviction and (2) had personally used a firearm in the commission of the robbery. See Cal.Penal Code §§ 211, 1170.12(c)(1), 12022.53(b). Petitioner was sentenced to twenty-two years in state prison. The sentence consisted of an upper-term sentence of six years for the robbery, doubled because of the prior strike conviction, plus a consecutive ten-year enhancement for the use of a firearm. After sentencing, Petitioner filed a direct appeal, claiming a Blakely violation, among other things. See Blakely v. Washington, 542 U.S. 296, 124 S.Ct. 2531, 159 L.Ed.2d 403 (2004) (holding that the Sixth Amendment right to a jury trial prohibits judges from enhancing criminal sentences beyond the statutory maximum based on facts other than those decided by the jury or admitted by the defendant). Petitioner argued that "the trial court violated his right to have a jury determine beyond a reasonable doubt the truth of the facts used to support imposition of the aggravated term." The state appellate court determined that the trial court did not deprive Petitioner of his constitutional right to a jury trial, and affirmed the judgment of the trial court.
Two years later, the United States Supreme Court decided Cunningham v. California, 549 U.S. 270, 127 S.Ct. 856, 166 L.Ed.2d 856 (2007). In Cunningham, the Court held that California's determinate sentencing law violated the Sixth Amendment because it allowed the sentencing court to impose an upper-term sentence based on aggravating facts it found to exist only by a preponderance of the evidence. Id. at 274., 127 S.Ct. 856 The Court concluded that the middle term is the relevant statutory maximum under California law, and it held that judges do not have the discretion to choose to impose an upper-term sentence unless that sentence is justified by additional facts that have been found by a jury beyond a reasonable doubt. Id. at 288-90, 127 S.Ct. 856.
After the Court decided Cunningham, Petitioner filed a petition for a writ of habeas corpus in the Northern District of California. Applying Blakely, the district court found a constitutional error in Petitioner's sentencing, because the "upper term base sentence he received was not permitted based on [his three] admissions" contained in the record. The district court also found that this error was not harmless, as "the record here simply does not have any evidence, let alone uncontroverted and overwhelming evidence, to support the imposition of the upper term on the robbery."
The district court granted the writ of habeas corpus, determining that Petitioner's total sentence "should be" eighteen years (based on the middle-term sentence *1184 of four years) instead of twenty-two years (based on the upper-term sentence of six years). The district court also ordered that "the State of California shall cause Chioino's sentence in Monterey County Superior Court Case No. SS022872 to be fixed in accordance with this order. This court leaves it to state officials to determine the appropriate procedure to fix the unconstitutional sentence, i.e., whether state law requires that Chioino be resentenced or require[s] an amended abstract of judgment to correct the sentence or required correction in another way."
In response, Respondent filed a motion under Federal Rule of Civil Procedure 59(e) to alter or amend the judgment. Respondent argued that the district court committed clear error in "fashion[ing] a new sentence without remanding to the trial court for a new sentencing hearing." Respondent argued that the appropriate remedy was to direct the state to hold a new sentencing hearing pursuant to California's reformed sentencing system, as set forth in People v. Sandoval, 41 Cal.4th 825, 62 Cal.Rptr.3d 588, 161 P.3d 1146 (2007).
The district court denied Respondent's Rule 59(e) motion, holding that Sandoval "does not lead to the conclusion that this court committed clear error in the remedy it chose upon finding a Sixth Amendment violation in the sentence" and that "serious ex post facto concerns are raised in resentencing under a newly reformed sentencing scheme." Respondent now appeals, claiming that the district court erred in ordering Petitioner's upper-term sentence reduced to a middle-term sentence without providing Respondent the option of holding a new sentencing hearing.[1]
We have jurisdiction under 28 U.S.C. §§ 2253(a) & 2254. A district court's ruling on the appropriate remedy for a constitutional violation on a habeas petition is reviewed for abuse of discretion. Riggs v. Fairman, 399 F.3d 1179, 1181(9th Cir.2005).

DISCUSSION
Respondent argues that the district court erred by ordering that Petitioner's six-year upper-term sentence be reduced to a four-year middle-term sentence. The Supreme Court has instructed that "[f]ederal habeas corpus practice, as reflected by the decisions of this Court, indicates that a court has broad discretion in conditioning a judgment granting habeas relief. Federal courts are authorized, under 28 U.S.C. § 2243, to dispose of habeas corpus matters `as law and justice require.'" Hilton v. Braunskill, 481 U.S. 770, 775, 107 S.Ct. 2113, 95 L.Ed.2d 724 (1987). Habeas remedies "`should put the defendant back in the position he would have been in if the Sixth Amendment violation never occurred.' " Nunes v. Mueller, 350 F.3d 1045, 1057(9th Cir.2003) (quoting United States v. Blaylock, 20 F.3d 1458, 1468 (9th Cir. 1994)). "[U]nless the district court abused its discretion in fashioning a remedy, that remedy must stand." Riggs v. Fairman, 399 F.3d at 1184. However, "the fact that the writ has been called an `equitable' remedy does not authorize a court to ignore... statutes, rules, and precedents.... Rather, courts of equity must be governed *1185 by rules and precedents no less than the courts of law." Lonchar v. Thomas, 517 U.S. 314, 323, 116 S.Ct. 1293, 134 L.Ed.2d 440 (1996) (citations and internal quotation marks omitted).
Respondent argues that the district court abused its discretion because its reduction of Petitioner's sentence rested "on an inaccurate view of California law." The California Supreme Court's opinion in People v. Sandoval delineated the procedure for cases remanded to a state trial court for resentencing because of a Cunningham violation. Sandoval, 41 Cal.4th at 845-46, 62 Cal.Rptr.3d 588, 161 P.3d 1146(noting that the California Supreme Court has "the responsibility and authority to fashion a constitutional procedure for resentencing in cases in which Cunningham requires a reversal of an upper term sentence").[2] The court also held that resentencing following a discretionary resentencing scheme is preferable to the alternative of "maintaining the requirement that the middle term be imposed in the absence of aggravating or mitigating factors but permitting a jury trial on aggravating circumstances." Id. at 848, 62 Cal. Rptr.3d 588, 161 P.3d 1146. Sandoval eliminated the presumption for a middle-term sentence and gave the trial court the discretion to impose the upper term on remand without a jury trial on factual findings. Id. at 843-45, 62 Cal.Rptr.3d 588, 161 P.3d 1146.
When it denied Respondent's Rule 59(e) motion to amend, the district court worried that applying Sandoval and remanding for resentencing under the newly formed discretionary scheme would raise ex post facto concerns. Those concerns were unwarranted. Sandoval itself held that resentencing under the newly reformed scheme was not controlled by the test set forth in Miller v. Florida, 482 U.S. 423, 107 S.Ct. 2446, 96 L.Ed.2d 351 (1987), "because the prohibition on ex post facto laws applies only to statutory enactments, not to judicial decisions." Sandoval, 41 Cal.4th at 855, 62 Cal.Rptr.3d 588, 161 P.3d 1146. We have also determined that no ex post facto concerns are generated by remanding for resentencing for a Cunningham violation if the sentencing court follows the California Supreme Court's instructions in Sandoval. Butler v. Curry explained:
In People v. Sandoval, 41 Cal.4th 825, 62 Cal.Rptr.3d 588, 161 P.3d 1146 (2007), the California Supreme Court addressed the appropriate procedure for resentencing individuals who had been sentenced under the prior version of the law, and concluded that it need not decide whether the 2007 amendments to the penal code were retroactive, because it could simply judicially "reform" the previous law to require sentencing in accordance with the principles of the 2007 amendments. Id. at 849, 62 Cal.Rptr.3d 588, 161 P.3d 1146.
[Petitioner] argues that applying this judicial reformation of the law violates the ex post facto principles contained in the Due Process Clause of the Fourteenth Amendment. See Bouie v. City of Columbia, 378 U.S. 347, 352-55, 84 S.Ct. 1697, 12 L.Ed.2d 894 (1964). As [Petitioner] acknowledges, however, this question is controlled by United States v. Dupas, 419 F.3d 916(9th Cir.2005), in which we held that retroactive application of the remedial opinion in Booker does not violate the Due Process Clause. Id. at 921.
Butler, 528 F.3d at 652 n. 20. Thus, the district court's order denying the motion to amend was based on an inaccurate view of both California and Ninth Circuit law. *1186 Remanding to the state trial court for resentencing under the Sandoval procedure raises no ex post facto concerns.
Respondent also argues that because Cunningham set out the right to a particular sentencing procedure rather than a substantive right to a particular sentence, the appropriate remedy for a Cunningham violation is to remand for a new sentencing hearing that utilizes a constitutional procedure. We agree. As the Supreme Court explained in United States v. Morrison, 449 U.S. 361, 101 S.Ct. 665, 66 L.Ed.2d 564 (1981), habeas remedies "should not unnecessarily infringe on competing interests" such as a state's "interest in the administration of criminal justice." Id. at 364, 101 S.Ct. 665. California has clarified what it believes to be the proper procedure for resentencing due to a Cunningham violation through both legislative and judicial action. See 2007 Cal. Stats., ch. 3, § 2 (West) (amending section 1170(b) of the California Penal Code to comply with the constitutional requirements of Cunningham); People v. Sandoval, 41 Cal.4th at 843-45, 62 Cal.Rptr.3d 588, 161 P.3d 1146 (reforming prior statute to conform to the newly amended statute for all Cunningham resentencings). Here, the district court's responsibility was to ensure that Petitioner was sentenced utilizing a constitutionally sound procedure, and it is the state court's responsibility to determine the procedure that satisfies the Sixth Amendment and Cunningham.
Once it found a Cunningham violation, the district court should have remanded to the state trial court for resentencing instead of ordering the state trial court to reduce the sentence in accordance with the district court's order. Even though the district court here believed there were no aggravating factors in the record that could have supported the upper-term sentence, a remand to the state trial court for resentencing under the procedures delineated in Sandoval was still required. The district court abused its discretion by resentencing Petitioner itself instead of remanding to the state trial court to utilize California's reformed system.

CONCLUSION
The district court is directed to amend its order to require that the matter be remanded to the state trial court for resentencing.
REVERSED and REMANDED.
NOTES
[*]  The panel unanimously finds this case suitable for decision without oral argument. See Fed. R.App. P. 34(a)(2).
[1]  Respondent also argues that the district court erred by retroactively applying Cunningham v. California, 549 U.S. 270, 127 S.Ct. 856, 166 L.Ed.2d 856 (2007). We have since held that where a federal habeas petitioner's conviction became final between Blakely and Cunningham, the rule in Cunningham should be retroactively applied under Teague v. Lane, 489 U.S. 288, 109 S.Ct. 1060, 103 L.Ed.2d 334 (1989). Butler v. Curry, 528 F.3d 624, 639 (9th Cir.2008). Accordingly, Cunningham's retroactivity is settled law in this circuit, and thus Respondent's additional argument fails.
[2]  As the district court recognized, Sandoval involved a case on direct appeal and did not explicitly discuss the appropriate procedure for habeas corpus petitions.
