
821 S.W.2d 154 (1991)
James M. HUGHES and Patti Hughes, Petitioners,
v.
MAHANEY & HIGGINS, Robert M. Mahaney and Hugh B. Higgins, Respondents.
No. D-0678.
Supreme Court of Texas.
November 20, 1991.
Rehearing Overruled February 5, 1992.
*155 Scott A. Stewart, Dallas, for petitioners.
Robert E. Aldrich and J.K. Leonard, Fort Worth, for respondents.

OPINION [OOJ] CORNYN, Justice.
This case decides the proper application of the statute of limitations in a legal malpractice case when the attorney allegedly commits malpractice while providing legal services in the prosecution or defense of a claim which results in litigation. The trial court granted the attorneys' motion for summary judgment based on their affirmative defense of limitations, and the court of appeals affirmed. 822S.W.2d63. We hold that the statute of limitations was tolled until all appeals were exhausted on the underlying suit in which the malpractice allegedly occurred. Consequently, the statute of limitations did not bar the Hugheses' suit. Thus, we reverse the judgment of the court of appeals and remand the cause for trial.
In October 1982, James and Patti Hughes retained attorney Robert M. Mahaney to assist them with the adoption of a child. As planned, the day the child was born Mahaney obtained a signed affidavit of relinquishment of parental rights, irrevocable for 60 days, from the child's biological mother. However, the affidavit named Mahaney, rather than the Hugheses, temporary managing conservator of the child. The next day, Mahaney filed suit on behalf of the Hugheses to terminate the biological mother's parental rights and for adoption of the child.
The biological mother, however, had a change of heart and revoked her affidavit of relinquishment on February 17, 1983, after the period of irrevocability expired. She then filed an application for writ of habeas corpus against Mahaney seeking possession of the child.[1] The Hugheses thereafter amended their pleadings to assert grounds for involuntary termination of the parent-child relationship, alleging: 1) that the biological parents left the child in possession of another with the express intention not to return; and 2) that the biological parents abandoned the child without providing adequate support for three months. Following an evidentiary hearing, the trial court denied the writ of habeas corpus and appointed the Hugheses temporary managing conservators of the child.
The biological parents then filed a motion to dismiss the Hugheses' suit on the ground that the Hugheses lacked standing under section 11.03(a) of the Texas Family Code to bring a suit affecting the parentchild relationship. Before the motion to dismiss was heard, and denied, and the *156 termination of parental rights case was tried, Mahaney withdrew as the Hugheses' attorney because of the likelihood that he would be called to testify as a fact witness. Based on the jury's verdict, the trial court rendered judgment awarding the Hugheses custody and terminating the biological parents' rights.
The biological parents appealed, and on March 7, 1985, the Waco court of appeals reversed the trial court's judgment and ordered the trial court to dismiss the Hugheses' suit on the ground that they lacked standing to seek the termination of parental rights. In their subsequent malpractice action, the Hugheses alleged that the Waco court of appeals would have decided the standing issue in their favor had Mahaney named the Hugheses temporary managing conservators in the affidavit of relinquishment of parental rights rather than Mahaney. The Hugheses filed an application for writ of error in the termination of parental rights case, which we denied. We overruled their motion for rehearing on July 10, 1985.
The Hugheses then sued Mahaney, his partner and his law firm (hereinafter, collectively referred to as Mahaney) on May 21, 1987, alleging causes of action under the Texas Deceptive Trade Practices-Consumer Protection Act (DTPA)[2] and for negligence. In their first amended petition, they alleged that Mahaney: (1) violated the DTPA by warranting that he would obtain termination of the biological parents' rights during the sixty day period that the affidavit of relinquishment was irrevocable; (2) negligently named himself temporary managing conservator in the affidavit of relinquishment; and (3) negligently researched the law applicable to the adoption. They also alleged that Mahaney fraudulently concealed his failure to obtain an order terminating parental rights by telling the Hugheses that he had been unable to schedule a hearing due to the trial court's busy docket.
Mahaney filed a motion for summary judgment, asserting that the two-year statute of limitations barred the Hugheses' suit.[3]See TEX.CIV.PRAC. & REM.CODE § 16.003(a). The trial court granted Mahaney's motion. The court of appeals affirmed the judgment, holding that the Hugheses' cause of action for Mahaney's alleged malpractice accrued when the Waco court of appeals issued its opinion on March 7, 1985 by operation of the discovery rule. 822 S.W.2d at 66. We need not decide when the Hugheses' cause of action against Mahaney accrued, however, because regardless of the date it accrued we hold that the statute of limitations was tolled until all of the Hugheses' appeals in the termination action were exhausted.
A cause of action for legal malpractice accrues when the client sustains a legal injury or, in cases governed by the discovery rule, when the client discovers or should have discovered the facts establishing the elements of a cause of action.[4]Smith v. McKinney, 792 S.W.2d 740, 742 (Tex.App.Houston [14th Dist] 1990, writ denied) (the legal injury rule); Willis v. Maverick, 760 S.W.2d 642, 643 (Tex.1988) (the discovery rule). However, when an attorney commits malpractice while providing legal services in the prosecution or defense of a claim which results in litigation, the legal injury and discovery rules can force the client into adopting inherently inconsistent litigation postures in the underlying case and in the malpractice case. This case demonstrates the untenability of that conflict.
*157 Mahaney argues that the Hugheses' malpractice cause of action accrued as early as February 17, 1983, the date that the biological mother revoked her affidavit of relinquishment. If this date of accrual is correct, and we express no opinion on whether it is, the Hugheses would have had to file suit against Mahaney within two years of that date in order to preserve their malpractice cause of action. During that same interval, however, the Hugheses were appealing the Waco court of appeals' judgment, of necessity claiming that Mahaney's actions were not fatal to their claims. Specifically, had the Hugheses sued Mahaney for malpractice while seeking to overturn the Waco court of appeals decision, they would have been placed in the position of claiming that Mahaney committed malpractice in the handling of their termination of parental rights suit and that, but for Mahaney's negligence, the termination of parental rights and subsequent adoption would have succeeded. In pursuing their appeal of the underlying claim, however, the Hugheses had to make the inconsistent claim that Mahaney's actions were correct, or, at least not fatal to their claims. As a result of this conflict, the likelihood of their success in both suits would have been compromised.
Where "a person is prevented from exercising his legal remedy by the pendency of legal proceedings, the time during which he is thus prevented should not be counted against him in determining whether limitations have barred his right." Walker v. Hanes, 570 S.W.2d 534, 540 (Tex.Civ. App.Corpus Christi 1978, writ ref'd n.r.e.) (limitations tolled while prior submission of same case was being appealed); Cavitt v. Amsler, 242 S.W. 246, 249 (Tex.Civ.App. Austin 1922, writ dism'd) (limitations on suit for dividends tolled while suit to determine ownership of stock was being appealed); Pease v. State, 228 S.W. 269, 270-71 (Tex.Civ.App.El Paso 1921, writ ref'd) (plaintiff's cause of action in suit for salary did not accrue until final decision in quo warranto proceeding that defendant was not entitled to job); Fields v. Austin, 30 S.W. 386, 387 (Tex.Civ.App.1895, writ ref'd) (cause of action for rent did not accrue until appeals exhausted on suit to determine title to land).
We conclude that the rationale applied in these cases is also appropriate when a client's cause of action for malpractice arises during the attorney's prosecution or defense of a claim which results in litigation. Limitations are tolled for the second cause of action because the viability of the second cause of action depends on the outcome of the first.
Therefore, we hold that when an attorney commits malpractice in the prosecution or defense of a claim that results in litigation, the statute of limitations on the malpractice claim against the attorney is tolled until all appeals on the underlying claim are exhausted. We join other jurisdictions in adopting this well-reasoned rule.[5]
*158 Here, since the statute of limitations was tolled from the time the Hugheses' cause of action accrued until July 10, 1985, when we overruled the Hugheses' motion for rehearing on their application for writ of error in the termination of parental rights suit,[6] the lawsuit that the Hugheses filed against Mahaney on May 21, 1987, is not barred by the two year statute of limitations. TEX.CIV.PRAC. & REM.CODE § 16.003(a). Therefore, the trial court erred when it granted Mahaney's motion for summary judgment on the defense of limitations.
For the foregoing reasons, we reverse the judgment of the court of appeals and remand this cause to the trial court for further proceedings consistent with this opinion.
NOTES
[1]  Shortly after filing the application for writ of habeas corpus, the biological mother married the biological father. He then joined her suit for possession of the child.
[2]  TEX.BUS. § 17.41-.63.
[3]  The defendants also moved for summary judgment based upon the two-year statute of limitations under the DTPA. TEX.BUS. & COM.CODE § 17.565. The Hugheses did not challenge the trial court's rendition of summary judgment on this cause of action.
[4]  Although section 16.003(a) of the Texas Civil Practice and Remedies Code states that a suit must be brought within two years after a cause of action accrues, it is a judicial function "to determine when a cause of action accrues and thus when the statute of limitations commences." Willis v. Maverick, 760 S.W.2d 642, 644 (Tex.1988).
[5]  See Bonanno v. Potthoff, 527 F.Supp. 561, 565 (N.D.Ill.1981) (applying Illinois law); Amfac Dist. Corp. v. Milter, 138 Ariz. 152, 673 P.2d 792, 793 (1983); Peat, Marwick, Mitchell & Co. v. Lane, 565 So.2d 1323, 1326 (Fla.1990); Neylan v. Moser, 400 N.W.2d 538, 542 (Iowa 1987); Semenza v. Nevada Medical Liability Ins. Co., 104 Nev. 666, 765 P.2d 184, 186 (1988). These cases turn on other policy considerations unnecessary to our decision today. See, e.g., Amfac Dist. Corp. v. Milter, 138 Ariz. 155, 673 P.2d 795, 797 (Ct.App.1983), aff'd as supplemented, 138 Ariz. 152, 673 P.2d 792, 793 (1983).

However, other jurisdictions have rejected the "exhaustion of appeals" rule. These courts hold that the statute of limitations runs from the time the cause of action accrues although they acknowledge the possibility that the underlying case may be reversed on appeal and that, as a result, the amount of the client's damages is speculative. They decline to toll the statute of limitations until damages have been fully ascertained. See Wettanen v. Cowper, 749 P.2d 362, 365 (Alaska 1988); Zupan v. Berman, 142 Ill. App.3d 396, 96 IlI.Dec. 889, 891, 491 N.E.2d 1349, 1351 (1986); Sabes & Richman, Inc. v. Muenzer, 431 N.W.2d 916, 918-19 (Minn Ct.App. 1988); Dixon v. Shafton, 649 S.W.2d 435, 438 (Mo.1983); Suzuki v. Holthaus, 221 Neb. 72, 375 N.W.2d 126, 128 (1985); Zimmie v. Calfee, Halter & Griswold, 43 Ohio St.3d 54, 538 N.E.2d 398, 402 (1989); Chambers v. Dillow, 713 S.W.2d 896, 898 (Tenn.1986); Richardson v. Denend, 59 Wash.App. 92, 795 P.2d 1192, 1195 n. 7 (1990). Still other courts reject "exhaustion of appeals" because of their overriding concern with the prejudice caused by delay as the underlying case works its way through the appellate process. Laird v. Blacker, 229 Cal.App.3d 159, 279 Cal.Rptr. 700, 711 (1991); Hennekens v. Hoerl, 160 Wis.2d 144, 465 N.W.2d 812, 818 (1991). Because we base our decision today on a different and more fundamental policy consideration, we do not address the policy considerations advanced by other jurisdictions.
[6]  We hold that the tolling of the statute of limitations on the Hugheses malpractice case ended when we overruled the Hugheses' motion for rehearing because the last action of right that they could take and did take on the underlying case was concluded on that date.
