                 FOR PUBLICATION
 UNITED STATES COURT OF APPEALS
      FOR THE NINTH CIRCUIT

MICHAEL HUFTILE,                          No. 03-16734
              Plaintiff-Appellant,           D.C. No.
               v.                       CV-03-01522-FCD/
L C MICCIO-FONSECA,                            DAD
             Defendant-Appellee.
                                            OPINION

       Appeal from the United States District Court
          for the Eastern District of California
       Frank C. Damrell, District Judge, Presiding

                Argued and Submitted
      December 10, 2004—San Francisco, California

                   Filed June 10, 2005

      Before: Alex Kozinski, William A. Fletcher, and
               Jay S. Bybee, Circuit Judges.

          Opinion by Judge William A. Fletcher




                           6789
                  HUFTILE v. MICCIO-FONSECA             6791


                        COUNSEL

Michael Huftile, Pro Se, San Luis Obispo, California, Melissa
A. Jones, J. Michael Stusiak, Morrison & Foerster, Sacra-
mento, California, for the plaintiff-appellant.
6792              HUFTILE v. MICCIO-FONSECA
Margarita Altamirano, Office of the California Attorney Gen-
eral, Sacramento, California, for the defendant-appellee and
for amicus California Department of Mental Health.


                            OPINION

W. FLETCHER, Circuit Judge:

   In this case, we must decide a question of first impression:
Does the favorable termination rule of Heck v. Humphrey,
512 U.S. 477 (1994), apply to civil commitments under Cali-
fornia’s Sexually Violent Predators Act? We conclude that the
Heck rule applies. We therefore affirm the district court’s dis-
missal of Huftile’s § 1983 action for damages and declaratory
relief. However, we reverse the dismissal of his claim for pro-
spective injunctive relief under Heck, and remand for further
proceedings concerning this form of relief.

                       I.   Background

  Michael Huftile filed a 42 U.S.C. § 1983 complaint seeking
damages, declaratory relief, and injunctive relief against Dr.
L.C. Miccio-Fonseca in federal district court on July 17,
2003. When he filed the complaint, Huftile was being
detained under California’s Sexually Violent Predators Act
(“SVPA”). The SVPA provides for a two-year term of civil
commitment if a court or jury determines beyond a reasonable
doubt that an individual is a “sexually violent predator.” Cal.
Welf. & Inst. Code § 6604. Huftile contends that Dr. Miccio-
Fonseca’s “policies, practices, and customs” in performing an
SVPA evaluation of him violated his constitutional rights to
due process, privacy, and equal protection.

  The events underlying Huftile’s complaint occurred when
Huftile was incarcerated at California Men’s Colony in San
Luis Obispo. According to Huftile’s complaint, Dr. Miccio-
                  HUFTILE v. MICCIO-FONSECA                6793
Fonseca met with him on February 2, 2001, to initiate an
SVPA evaluation. Dr. Miccio-Fonseca presented Huftile with
a “Notice of Evaluation as a Sexually Violent Predator.” Huf-
tile signed the form to indicate that he refused to be inter-
viewed by Dr. Miccio-Fonseca. Huftile alleges that he
understood that this refusal would bar Dr. Miccio-Fonseca
from reviewing his confidential records. According to the
complaint, Dr. Miccio-Fonseca again attempted to interview
Huftile on July 3, 2002. Huftile alleges that Dr. Miccio-
Fonseca informed him that he was under a court order requir-
ing him to speak with her. He further alleges that Dr. Miccio-
Fonseca could not produce a copy of the court order and did
not tape the interview as required in the order.

   According to Huftile’s complaint, Dr. Miccio-Fonseca pre-
pared a report and later testified against Huftile at the SVPA
civil commitment trial. Huftile alleges that because he did not
consent to be interviewed, Dr. Miccio-Fonseca’s evaluation
was based solely on Huftile’s record, including Huftile’s Cali-
fornia Department of Corrections Central File. Huftile further
alleges that Dr. Miccio-Fonseca accessed his confidential
records without his consent, failed to follow proper proce-
dures in conducting interviews, fabricated portions of her
report, and relied on stale data in preparing the report.

   Huftile requested leave to proceed in forma pauperis in the
district court pursuant to 28 U.S.C. § 1915. The magistrate
judge granted in forma pauperis status and recommended that
Huftile’s action be dismissed for failure to state a claim under
28 U.S.C. § 1915(e)(2)(B)(ii). The magistrate judge con-
cluded that Heck v. Humphrey barred Huftile’s suit because
he challenged the validity of a mental health assessment
underlying his civil commitment, and because that commit-
ment had not been “reversed on direct appeal, expunged by
executive order, declared invalid by a state tribunal authorized
to make such determination, or called into question by a fed-
eral court’s issuance of a writ of habeas corpus” (quoting
Heck, 512 U.S. at 487) (internal quotation marks omitted).
6794               HUFTILE v. MICCIO-FONSECA
The district court adopted the findings and recommendations
of the magistrate judge. Huftile timely appealed. We review
de novo a dismissal under 28 U.S.C. § 1915(e)(2)(B)(ii) in the
same manner as a dismissal under Federal Rule of Civil Pro-
cedure 12(b)(6). See Barren v. Harrington, 152 F.3d 1193,
1194 (9th Cir. 1998).

                         II.   Analysis

  [1] In Heck v. Humphrey, the Supreme Court held that

     when a state prisoner seeks damages in a § 1983 suit,
     the district court must consider whether a judgment
     in favor of the plaintiff would necessarily imply the
     invalidity of his conviction or sentence; if it would,
     the complaint must be dismissed unless the plaintiff
     can demonstrate that the conviction or sentence has
     already been invalidated.

512 U.S. at 487. Huftile contends that Heck’s favorable termi-
nation rule does not bar his action because either (1) Heck
does not apply to suits brought by civil detainees or (2) his
suit does not “necessarily imply” the invalidity of his continu-
ing confinement. Huftile also argues that even if Heck would
otherwise apply, his subsequent release from Department of
Mental Health custody and his concomitant inability to peti-
tion for habeas corpus relief allow him to maintain a § 1983
action. We consider these arguments in turn.

A.     Applicability of Heck v. Humphrey to SVPA Detainees

   Huftile argues that Heck’s references to “a state prisoner”
indicate that the favorable termination rule applies only to
“prisoners” convicted of criminal offenses. There is some
support for this argument. In creating the favorable termina-
tion rule in Heck, the Court relied on “the hoary principle that
civil tort actions are not appropriate vehicles for challenging
the validity of outstanding criminal judgments.” Id. at 486
                    HUFTILE v. MICCIO-FONSECA                  6795
(emphasis added). SVPA commitment, by contrast, is a civil
proceeding. See Hubbart v. Superior Court, 19 Cal. 4th 1138,
1166 (1999) (stating that the SVPA is a “nonpunitive, civil
commitment scheme”). Huftile also relies on our decision in
Page v. Torrey, 201 F.3d 1136 (9th Cir. 2000), in which we
held that an SVPA detainee was not a “prisoner” for the pur-
poses of the exhaustion and financial reporting requirements
of the Prison Litigation Reform Act (“PLRA”), id. at 1140.
The PLRA defines “prisoner” as “any person incarcerated or
detained in any facility who is accused of, convicted of, sen-
tenced for, or adjudicated delinquent for, violations of crimi-
nal law or the terms and conditions of parole, probation,
pretrial release, or diversionary program.” 28 U.S.C.
§ 1915(h). In Page, we held that the “natural reading” of
“prisoner” required that “the individual in question must be
currently detained as a result of accusation, conviction, or
sentence for a criminal offense.” 201 F.3d at 1139.

   However, the PLRA definition of “prisoner” does not mark
the outer boundary of Heck’s favorable termination rule. Heck
dealt with the “intersection of the two most fertile sources of
federal-court prisoner litigation” — the basic federal civil
rights statute, 42 U.S.C. § 1983, and the federal habeas corpus
statute for state prisoners, 28 U.S.C. § 2254. 512 U.S. at 480.
In Muhammad v. Close, 540 U.S. 749 (2004), the Supreme
Court explained that Heck’s favorable termination rule
“served the practical objective of preserving limitations on the
availability of habeas remedies. Federal petitions for habeas
corpus may be granted only after other avenues of relief have
been exhausted. Prisoners suing under § 1983, in contrast,
generally face a substantially lower gate . . . .” Id. at 751 (cita-
tions omitted). In Ramirez v. Galaza, 334 F.3d 850 (9th Cir.
2003), we noted that the differing exhaustion requirements of
§ 1983 and § 2254 “left the two statutes on a ‘collision
course.’ ” Id. at 855 (quoting Heck, 512 U.S. at 492 (Souter,
J., concurring in the judgment)).

  [2] Heck’s favorable termination rule was intended to pre-
vent a person in custody from using § 1983 to circumvent the
6796               HUFTILE v. MICCIO-FONSECA
more stringent requirements for habeas corpus. Unlike the
PLRA, the habeas statute is not textually limited to “prison-
ers.” Rather, § 2254 directs that a federal court “shall enter-
tain an application for a writ of habeas corpus in behalf of a
person in custody pursuant to the judgment of a State court.”
28 U.S.C. § 2254(a) (emphasis added). It is well established
that detainees under an involuntary civil commitment scheme
such as SVPA may use a § 2254 habeas petition to challenge
a term of confinement. See Duncan v. Walker, 533 U.S. 167,
176 (2001) (stating that a state court order of civil commit-
ment satisfies § 2254’s “in custody” requirement). We there-
fore conclude that Heck applies to SVPA detainees with
access to habeas relief.

         B.   Applicability of Heck to Huftile’s Suit

   Huftile asserts that even if Heck’s favorable termination
rule applies to SVPA detainees in general, it does not apply
to his suit. He contends that his § 1983 suit is cognizable
because he is challenging the procedures used to evaluate him
under the SVPA, not the substantive merits of his underlying
civil commitment. Therefore, he argues, a judgment in his
favor would not “necessarily imply the invalidity” of his com-
mitment or confinement.

   The Supreme Court has instructed, however, that Heck
envisioned “the possibility . . . that the nature of the challenge
to the procedures could be such as necessarily to imply the
invalidity of the judgment.” Edwards v. Balisok, 520 U.S.
641, 645 (1997). In Balisok, the alleged procedural violations
involved a hearing officer’s decision, motivated by “deceit
and bias,” to exclude exculpatory evidence in a disciplinary
proceeding. Id. at 646-47. The Balisok Court reasoned that a
“criminal defendant tried by a partial judge is entitled to have
his conviction set aside, no matter how strong the evidence
against him.” Id. at 647. It therefore concluded that Balisok’s
§ 1983 claim for declaratory relief and money damages neces-
                    HUFTILE v. MICCIO-FONSECA                  6797
sarily implied the invalidity of the disciplinary action and ren-
dered his claim not cognizable under Heck. Id. at 648.

   [3] Huftile’s § 1983 claim is factually similar to that in But-
terfield v. Bail, 120 F.3d 1023 (9th Cir. 1997). In Butterfield,
the prisoner-plaintiff brought a § 1983 suit on the ground that
the parole board allegedly relied on false information in his
prison file to deny him parole. Id. at 1024. We held that Heck
applied:

      Butterfield alleges that defendants violated his due
      process rights by considering false information in his
      prison file to find him ineligible for parole. We have
      no difficulty in concluding that a challenge to the
      procedures used in the denial of parole necessarily
      implicates the validity of the denial of parole and,
      therefore, the prisoner’s continuing confinement.

Id.

   [4] In determining whether a judgment in favor of a § 1983
plaintiff necessarily implies the invalidity of his underlying
conviction, we take into account the particular facts of the
criminal trial or other proceeding leading to the allegedly
improper detention. In Heck, for example, the Supreme Court
stated in a footnote that a challenge to an allegedly unreason-
able search “would not necessarily imply that the plaintiff’s
conviction was unlawful” because of doctrines such as inde-
pendent source, inevitable discovery, and harmless error. 512
U.S. at 487 n.7. In this circuit, we have held that an unreason-
able search necessarily implies the invalidity of a conviction
where the evidence seized was “an essential element” in “the
present case.” Harvey v. Waldron, 210 F.3d 1008, 1015-16
(9th Cir. 2000).

   [5] The district court record does not include a transcript of
Huftile’s civil commitment proceeding. However, the struc-
ture of the SVPA statutory scheme indicates that the success
6798              HUFTILE v. MICCIO-FONSECA
of Huftile’s § 1983 claim would necessarily imply the invalid-
ity of his civil commitment. Before the California Director of
Mental Health can forward a request for an SVPA commit-
ment petition to the appropriate county, two evaluators must
agree that “the person has a diagnosed mental disorder so that
he or she is likely to engage in acts of sexual violence without
appropriate treatment and custody.” Cal. Welf. & Inst. Code
§ 6601(d). An attorney for that county may then file a petition
for commitment. Id. § 6601(i). A judge must then review this
petition to determine whether there is probable cause to
believe that the person “is likely to engage in sexually violent
predatory criminal behavior” upon release. Id. § 6602(a).
Because Dr. Miccio-Fonseca was one of Huftile’s evaluators,
a judgment in favor of Huftile in his § 1983 action would nec-
essarily imply the invalidity of his civil commitment. That is,
if only one evaluator, rather than two, had concluded that
Huftile had a “mental disorder” within the meaning of
§ 6601(d), there would have been no basis for the state Direc-
tor of Mental Health to send the request to the county, no
basis for the county attorney to file a petition for commitment,
and no basis for the judge to go forward with a probable cause
determination.

   [6] In addition to seeking monetary damages and declara-
tory relief, Huftile seeks injunctive relief that would “pre-
vent[ ] Defendant from inflicting further injury” upon him.
The Supreme Court stated in Balisok that “[o]rdinarily, a
prayer for . . . prospective relief will not ‘necessarily imply’
the invalidity of a previous loss of good-time credits, and so
may properly be brought under § 1983.” 520 U.S. at 648.
While Huftile’s claims for damages and declaratory relief are
barred by Heck, Huftile’s claim for injunctive relief is not
barred. We therefore reverse the portion of the district court’s
order finding a Heck bar to injunctive relief. We do not decide
whether Huftile is, in fact, entitled to injunctive relief. On
remand, the district court will be free, through appropriate
procedures, to decide on the propriety of such relief.
                       HUFTILE v. MICCIO-FONSECA                        6799
           C.    Availability of Habeas Corpus Review

   [7] In Spencer v. Kemna, 523 U.S. 1 (1998), five Justices
endorsed the idea that the unavailability of habeas relief per-
mits a § 1983 action, regardless of whether the success of the
action would necessarily imply the invalidity of the convic-
tion or sentence.1 See also Muhammad, 540 U.S. at 752 n.2
(“Members of the Court have expressed the view that
unavailability of habeas for other reasons may also dispense
with the Heck requirement.”). Based on the separate opinions
in Spencer, we have held that in certain limited cases, Heck
does not bar a § 1983 claim if habeas relief is unavailable. See
Nonnette v. Small, 316 F.3d 872, 875-77 (9th Cir. 2002). Huf-
tile contended in his opening brief that even if his damages
suit would otherwise be barred by Heck, his § 1983 action
was cognizable because he was no longer civilly committed
and hence was unable to file a habeas corpus petition. Huftile
is now in recommitment proceedings. We must therefore
determine whether habeas relief is available to Huftile under
Heck, given his current custody status.

   Huftile’s initial term of civil commitment began on
November 19, 2002. After he filed his complaint in this case,
Huftile was transferred to the custody of the California
Department of Corrections to serve time for a parole viola-
tion. We have been informed in a post-argument submission
that probable cause for a recommitment trial was found on
March 14, 2005, and that a trial has been set for August 23,
  1
    Justice Souter, writing for four members of the Court in Spencer, stated
in a concurrence that “a former prisoner, no longer ‘in custody,’ may bring
a § 1983 action establishing the unconstitutionality of a conviction or con-
finement without being bound to satisfy a favorable-termination require-
ment that it would be impossible as a matter of law for him to satisfy.” 523
U.S. at 21 (Souter, J., concurring). Justice Stevens, in dissent, noted that
“[g]iven the Court’s holding that petitioner does not have a remedy under
the habeas statute, it is perfectly clear, as Justice Souter explains, that he
may bring an action under 42 U.S.C. § 1983.” Id. at 25 n.8 (Stevens, J.,
dissenting).
6800               HUFTILE v. MICCIO-FONSECA
2005. Huftile is being detained at Atascadero State Hospital
pending the civil recommitment trial. Dr. Miccio-Fonseca did
not conduct any of the evaluations underlying the state’s
recommitment petition.

   [8] Huftile still has standing to bring a federal habeas peti-
tion challenging his initial SVPA commitment even if the
term of that commitment has expired. In Jackson v. California
Department of Mental Health, 399 F.3d 1069 (9th Cir. 2005),
we considered the case of an SVPA detainee whose initial
term expired before he filed a federal habeas petition. Jack-
son’s standing was in doubt because his continuing confine-
ment was due to his voluntary recommitment after his initial
term had expired. We noted, however, that the standing analy-
sis would be different if Jackson had not voluntarily recom-
mitted himself. Had Jackson instead been involuntarily
committed under successive SVPA petitions, “any future peti-
tion to recommit him could be traced back, through preceding
petitions, to his initial confinement” because “his initial
SVPA confinement would have served as a prerequisite for a
second petition, the second petition as a prerequisite for a
third, and so forth.” Id. This is Huftile’s case. Under Califor-
nia’s SVPA scheme, the current petition to recommit Huftile
is directly traceable to his initial term of confinement and is
thereby sufficient to confer standing for federal habeas pur-
poses.

                          Conclusion

   [9] For the foregoing reasons, we affirm the district court’s
28 U.S.C. § 1915(e)(2)(B)(ii) dismissal of Huftile’s claim for
damages and declaratory relief, but we reverse the dismissal
of his claim for injunctive relief, and we remand to allow the
district court to address this claim. Because Huftile’s § 1983
claim for damages and declaratory relief will not accrue
unless and until his civil commitment is invalidated, we also
remand to allow the district court to dismiss this claim with-
out prejudice to Huftile’s later filing a § 1983 action if his
                  HUFTILE v. MICCIO-FONSECA             6801
civil commitment is invalidated. See Heck, 512 U.S. at 489-
90; Trimble v. City of Santa Rosa, 49 F.3d 583, 585 (9th Cir.
1995) (per curiam).

  AFFIRMED in part; REVERSED in part; REMANDED.
