Ronald Rooding filed a petition for writ of habeas corpus and, in the alternative, a petition for writ of mandamus in Illinois state court challenging the duration of his confinement. The court issued a writ of mandamus and ordered that Rooding be immediately *579released. Rooding subsequently filed an action under 42 U.S.C. § 1983 seeking damages on the ground that his extended confinement violated his rights to due process and equal protection. The district court dismissed Rooding’s complaint, finding that his § 1983 claim was barred by res judicata because Rooding could have recovered damages in his mandamus action. We reverse on the ground that because Rooding’s § 1983 claim did not accrue until after he was successful in his mandamus action, that claim is not barred by res judicata.
I
On November 17, 1993, Rooding was convicted of criminal damage to property and sentenced to one year of imprisonment. Under Illinois law and the custom or policy of the Illinois Department of Corrections (“IDOC”), Rooding was entitled to one day of good conduct credit for each day of imprisonment and 90 days of good conduct credit for meritorious service. As a result of those credits, Rooding’s one-year sentence should have translated into only 92 days of actual incarceration.
On November 19, Rooding was transferred to an IDOC facility. Prior to the transfer, Rooding had already served 71 days in non-ID OC facilities while awaiting the outcome of his trial. Thus, after being transferred to the IDOC facility, Rooding should only have been required to serve an additional 21 days. However, IDOC had a policy whereby all inmates in an IDOC facility must serve a minimum of 60 days. Rooding’s release date was set for January 19, 1994, 60 days following his transfer to the IDOC facility and 39 days after his term of incarceration should have ended.
On December 17, 1993, Rooding filed a petition for a writ of habeas corpus or, in the alternative, a petition for a writ of mandamus asking the Circuit Court of Cook County to require Howard Peters, III, the Director of IDOC, to immediately release Rooding. Rooding argued that his continued incarceration violated his rights to equal protection and due process because the length of his incarceration exceeded the length of incarceration served by a person serving an identical sentence who had been exclusively incarcerated in an IDOC facility. On December 22, the circuit court granted Rood-ing’s petition for writ of mandamus on equal protection grounds and issued a writ ordering his immediate release. Peters filed a motion for reconsideration, which was denied. He also filed an emergency order in the Illinois Court of Appeals to stay the trial court’s order, and that motion was denied. Rooding was released on January 6, 1994, 27 days after his term of incarceration should have ended.
On February 22, 1994, Rooding filed a verified class action complaint under 42 U.S.C. § 1983, alleging that Peters’s use of the unconstitutional sixty-day policy violated his rights to due process and equal protection. Peters moved for judgment on the pleadings, claiming Rooding should have brought his claim for damages in the state court mandamus proceeding and, because he did not, res judicata barred his § 1983 action.
The district court granted Peters’s motion for judgment on the pleadings. The district court noted that there was some question as to whether an inmate may join a § 1983 damages claim with a state mandamus action seeking his immediate release. Nevertheless, the district court found that the Illinois mandamus statute, 735 ILCS 5/14-105,1 provided Rooding with the opportunity to obtain damages and that Rooding’s failure to seek damages under that provision barred him from seeking damages in a subsequent § 1983 action. Rooding appeals, arguing that res judicata does not bar his § 1983 claim for damages because the cause of action did not accrue until after the issuance of the writ ordering his release.
II
We review a district court’s grant of a motion for judgment on the pleadings de novo. Alexander v. City of Chicago, 994 *580F.2d 333, 335 (7th Cir.1993). We take all well-pleaded allegations in the plaintiffs pleadings as true, viewing the inferences drawn from those allegations in the light most favorable to the plaintiff. Id. at 336. We will not affirm unless there are no genuine issues of material fact and the defendant is entitled to judgment as a matter of law. Id.
The doctrine of res judicata is fully applicable to civil rights claims brought pursuant to § 1983. Preiser v. Rodriguez, 411 U.S. 475, 497, 93 S.Ct. 1827, 1840, 36 L.Ed.2d 439 (1973). The res judicata effect of a state-court judgment upon a subsequent § 1983 action is a matter of state law. Migra v. Warren City Sch. Dist. Bd. of Educ., 465 U.S. 75, 85, 104 S.Ct. 892, 898, 79 L.Ed.2d 56 (1984). Thus, we must accord the writ at issue in this case the same preclusive effect that it would have in the Illinois courts.
Under Illinois law, a final judgment in one action acts as a bar to bringing a subsequent action where there are identity of the parties, subject matter, and causes of action. Torcasso v. Standard Outdoor Sales, Inc., 157 Ill.2d 484, 193 Ill.Dec. 192, 195, 626 N.E.2d 225, 228 (1993). The test for determining the identity of causes of action for res judicata purposes is whether the evidence needed to sustain the subsequent action would have sustained the original action. Id. “If the same facts are essential to maintain both proceedings or the same evidence is necessary to sustain the two, there is identity between the causes of action asserted, and res judicata bars the later one.” Id.
In Illinois, “the doctrine of res judicata extends not only to every matter that was actually determined in the prior suit but to every other matter that might have been raised and determined in it.” Id. However, res judicata will not bar litigation of an issue where a party did not have a full and fair opportunity to litigate the issue in the original case. Charles Koen & Assoes. v. City of Cairo, 909 F.2d 992, 1000 (7th Cir.1990). Finally, the party seeking to invoke res judicata bears the burden of proving its applicability. Torcasso, 193 Ill.Dec. at 195-96, 626 N.E.2d at 228-29.
Rooding argues that he did not have the opportunity to litigate his § 1983 damages claim in the mandamus action because the § 1983 cause of action did not accrue until after his term of incarceration was invalidated in the mandamus action. Peters’s response is that the mandamus statute, 735 ILCS 5/14H05, specifically allows for damages.
The United States Supreme Court recently held that an inmate may not file a § 1983 claim for damages that would call into question the lawfulness of his conviction or the duration of his confinement unless he can prove that he has already successfully challenged his conviction or the duration of his confinement. Heck v. Humphrey, — U.S. -, -, 114 S.Ct. 2364, 2372, 129 L.Ed.2d 383 (1994); see also Preiser, 411 U.S. at 500, 93 S.Ct. at 1841 (holding that inmate’s action seeking immediate release based on a challenge to the duration of his confinement on the ground he was unconstitutionally deprived of good time credits not cognizable under § 1983). The Court noted that a § 1983 claim is “a species of tort liability,” Heck, — U.S. at —, 114 S.Ct. at 2370 (quoting Memphis Community Sch. Dist. v. Stachura, 477 U.S. 299, 305, 106 S.Ct. 2537, 2542, 91 L.Ed.2d 249 (1986)), and that a § 1983 action seeking damages for an unlawful confinement or conviction is analogous to an action for malicious prosecution. Heck, — U.S. at -, 114 S.Ct. at 2370. A traditional element of a malicious prosecution claim is the termination of the prior proceeding in favor of the accused. Id. Following that analogy, the Court held that “in order to recover damages for allegedly unconstitutional conviction or imprisonment, or for other harm caused by actions whose unlawfulness would render a conviction or sentence invalid, a § 1983 plaintiff must prove that the conviction or sentence has been reversed [or otherwise invalidated].” Id. at -, 114 S.Ct. at 2372 (footnote omitted).
Rooding’s § 1983 claim for damages, challenging the duration of his confinement, is the type of § 1983 claim that would necessarily implicate the validity of his incarceration. Therefore, Rooding’s cause of action under § 1983 did not accrue until he prevailed in *581the mandamus action — he could not have joined the state habeas/mandamus action with his § 1983 action.
The particular type of § 1983 claim at issue both in this case and in Heck is distinguishable from most other types of § 1983 claims, whether arising in the civil or criminal context. Specifically, the malicious prosecution analogy used by the Court in Heck requires, as an element of that type of § 1983 claim, that the plaintiff prove that he prevailed in a prior proceeding invalidating his conviction or the duration of his confinement. Heck, — U.S. at -, 114 S.Ct. at 2371. As a result, the § 1983 action does not accrue until the prior proceeding is terminated in the inmate’s favor. Id. at -, 114 S.Ct. at 2372. Most other civil rights causes of actions accrue at the time the alleged injury occurred. See Palmer v. Board of Educ. Community Unit Sch. Dist., 46 F.3d 682, 685 (7th Cir.1995). And the failure to prosecute these § 1983 claims with other closely related claims may lead to the § 1983 claims being barred by res judicata.
In fact, in both Charles Koen & Assocs., 909 F.2d 992, and Wozniak v. County of DuPage, 845 F.2d 677 (7th Cir.1988), we held that Illinois’s law of res judicata barred a subsequent § 1983 claim for damages because that claim could and should have been raised in a prior mandamus action. The important distinction between those cases and this case is that, unlike the § 1983 actions in Charles Koen and Wozniak, Rood-ing’s § 1983 action did not accrue until after he was successful in the mandamus action.
Peters argues that even if the § 1983 cause of action was unavailable at the time of Rooding’s petition, Rooding lost his opportunity to seek damages under § 1983 by failing to request damages in his mandamus petition under 735 ILCS 5/14-105. We first note that there is some question as to whether Rooding could have been awarded damages under that section.2 But even if he could, his § 1983 claim would not be barred by res judicata. In answering this question, we must apply Illinois law. In Heck, the Supreme Court held that a § 1983 claim that would necessarily implicate the validity of a conviction or sentence is analogous to a claim for malicious prosecution. Thus, our focus must be on how Illinois applies res judicata to claims for malicious prosecution where the prior action that terminated in the plaintiffs favor provided him the opportunity to seek damages.
In Bank of Lyons v. Schultz, 78 Ill.2d 235, 35 Ill.Dec. 758, 399 N.E.2d 1286 (1980), the Illinois Supreme Court addressed the application of res judicata to a subsequent claim for malicious prosecution. The plaintiff in Bank of Lyons had been the subject of two wrongfully issued injunctions restraining the distribution of the proceeds of her husband’s life insurance. In each proceeding she sought and received damages, for a total of $24,103.52. After the injunction actions had been dismissed and she had been awarded damages, the plaintiff filed a malicious prosecution claim seeking additional damages on the ground that the wrongful injunctions caused the foreclosure of her house. Like Peters, the defendant in Bank of Lyons argued that the malicious prosecution suit was barred by res judicata because the plaintiff could have (and actually did) receive damages in the original action.
Assuming that she could have received the same damages she sought in her malicious prosecution claim in the earlier injunction actions, the Illinois Supreme Court nevertheless held that res judicata did not bar her malicious prosecution claim. Id. 35 Ill.Dec. at 761, 399 N.E.2d at 1289. According to the court,
[T]o have a cause of action for malicious prosecution, the suit which was wrongfully brought must have been determined in favor of the plaintiff. At the time the second injunction obtained by the bank had been dissolved, and when the plaintiff filed her second suggestion of damages, no cause of action for malicious prosecution could have arisen because the litigation *582brought against her by the bank had not yet been concluded in her favor.
Id.
Bank of Lyons sounds the death knell for Peters’s res judicata argument. Heck instructs us that § 1983 claims for damages like the one pursued by Rooding in this case are analogous to malicious prosecution claims in that they do not accrue until after the inmate’s sentence or conviction has been invalidated. And Bank of Lyons holds that malicious prosecution claims are not barred by res judicata even though the prior action, which terminated in the plaintiffs favor, offered her the opportunity to seek damages.
For the foregoing reasons, the order of dismissal is Reversed and this cause is Remanded for further proceedings consistent with this opinion.
. 735 ILCS 5/14-105 provides:
Judgment-Costs. If judgment is entered in favor of the plaintiff, the plaintiff shall recover damages and costs. If judgment is entered in favor of the defendant, the defendant shall recover costs.
. Although damages are specifically mentioned in the Illinois mandamus statute, Peters has been unable to cite, nor have we located, an Illinois case finding that damages are recoverable by a plaintiff-inmate in a mandamus action.