Plaintiff, John V. Harness, Jr., appeals from the dismissal with prejudice of his petition against defendant, State Farm Mutual Automobile Insurance Company. We reverse and remand.
Plaintiff owned an automobile insured by an automobile liability insurance policy issued by defendant. He permitted a person, whose identity is unknown, to operate the automobile while plaintiff was a passenger. The automobile was involved in a one car accident resulting from the driver’s negligence and causing bodily injury to plaintiff.
Plaintiff sought recovery against defendant under the uninsured motorist provisions of his insurance policy. When defendant declined coverage, plaintiff brought a petition in three counts against defendant seeking a declaratory judgment construing the applicable provisions of his policy of insurance; damages for breach of contract; and damages for vexatious refusal to pay damages. On motion of defendant, the trial court dismissed plaintiffs petition with prejudice for failure to state a cause of action.
On appeal the arguments of the parties are directed to the merits of plaintiffs underlying declaratory judgment action. Conceptually, it should be noted that the trial court’s ruling was a dismissal of plaintiffs petition for failure to state a claim upon which relief can be granted. The salient issue is whether the petition for declaratory judgment was sufficient to withstand a motion to dismiss. In reviewing the trial court’s dismissal, we accept as true all facts pleaded and all reasonable inferences drawn therefrom in order to determine whether the petition states any grounds for relief. Kanagawa v. State By and Through Freeman, 685 S.W.2d 831, 834 (Mo. banc. 1985).
Rule 87.02(a), on declaratory judgments, provides in pertinent part:
Any person interested under a deed, will, written contract or other writings constituting a contract, or whose rights, status or other legal relations are affected by a statute, municipal ordinance, contract or franchise, may have determined any question of construction or validity arising under the instrument, statute, ordinance, contract or franchise and obtain a declaration of rights, status or other legal relations thereunder.
Clearly, plaintiff is a person whose rights are affected by a contract and is entitled to a declaration of those rights under that contract. Rule 87.02(a); Millers Mut. Ins. Ass’n. v. Babbitt, 790 S.W.2d 944, 946 (Mo.App.1990). Under the pleadings, plaintiff is entitled to a declaration of his rights under the contract of insurance, even though he may have advanced a mistaken contention of law. City of Hannibal v. Marion County, 745 S.W.2d 842, 845 (Mo.App.1988). “A plaintiffs standing to claim declaratory relief — and to assert a legally protectible interest — is not impaired by the probability that ultimately he will not prevail.” Id. Having sufficiently pleaded the elements of a declaratory judgment action, plaintiff was entitled to win or lose after a submission of the issues raised therein on the merits.
Accordingly, we reverse the trial court’s dismissal of Count I and remand the cause for a hearing on the merits. Because the trial court’s ruling on Count II and III of plaintiffs petition was apparently predicated on its ruling on Count I, we also reverse the *593dismissal of those counts and remand for further proceedings.
REINHARD and CRIST, JJ., concur.