
389 P.2d 641 (1964)
COMMERCIAL UNION FIRE INSURANCE CO., a corporation, Plaintiff in Error,
v.
Roy O. KELLY, Defendant in Error.
No. 40305.
Supreme Court of Oklahoma.
February 18, 1964.
Hanson & Peterson, Oklahoma City, for plaintiff in error.
Eph Monroe, Clinton, for defendant in error.
*642 IRWIN, Justice.
Commercial Union Fire Insurance Co., a corporation, hereinafter referred to as insurer, brought an action in subrogation against Roy O. Kelly, referred to as defendant, to recover the sum of $2500.00 it had paid to its insured for loss sustained under the terms of a fire insurance policy. The trial court sustained defendant's demurrer to insurer's amended petition and on insurer's election to stand on its amended petition, the trial court dismissed the action. Insurer perfected the appeal under consideration.

PLEADINGS
Insurer alleged that defendant had leased from Mrs. L.G. Dean a certain filling station; that while the lease was in force, insurer had in effect with Mrs. Dean, a policy of fire insurance, insuring her against loss by fire to said property in the amount of $2500.00; that defendant, who was also a consignee of gasoline "* * * was delivering a load of gasoline to said filling station from a tank truck; that in the course of such operation * * * gasoline was permitted to spray out and become ignited, resulting in total loss of said building. * * *." Insurer further alleged the value of the building was at least $4279.00, and that it had paid the insured, Mrs. Dean, "* * * the sum of $2500.00, and in law and in equity, became subrogated to all her contract rights against defendant * * * as expressed in the lease contract." It was also alleged that Mrs. Dean and defendant had made a settlement and compromise concerning her loss in excess of the $2500.00.
Attached to the petition and made a part thereof was the lease contract between Mrs. Dean and defendant which contained, inter alia, the following provision:
"It is further agreed that Second Party (defendant) will deliver possession of said real estate to First Party (Mrs. Dean, the insured) upon the expiration of this lease in as good state of repair as said building is in at the present time, except for the usual wear and tear."
The defendant filed a demurrer which was sustained by the trial court on the grounds the amended petition failed to state a cause of action.

ISSUE
In examining the pleadings we find the liability of defendant, if any, must be based upon insurer's right to be subrogated to *643 the contractual obligations of defendant to Mrs. Dean, the insured, by virtue of it having paid to the insured the loss sustained under the terms of the fire insurance policy.
Therefore, the first issue to be resolved is whether an action in subrogation exists in favor of an insurance company against a third party, based on the contractual obligation of the third party to the insurance company's insured, where the insurance company has paid the claim of its insured for loss under the terms of fire insurance policy.

CONCLUSIONS
Title 36 O.S. 1961 § 4803, sets forth a printed form of a policy of fire insurance to be used in Oklahoma. This printed form contains the following provision: "Subrogation. This Company may require from the insured an assignment of all right of recovery against any party for loss to the extent that payment therefor is made by this Company."
The above provision specifically recognizes the right of subrogation when an insurance company has paid its insured under the terms of the fire insurance policy. The case of Harrington v. Central States Fire Ins. Co. of Wichita, Kan., 169 Okl. 255, 36 P.2d 738, 96 A.L.R. 859, recognizes the right of subrogation involving actionable negligence of a third party. Defendant relies upon this case to sustain his theory that the amended petition did not state a cause of action. Although the Harrington case recognizes the right of subrogation where an insurance company has paid a loss to its insured under the terms of the policy, the law set forth in that case is not controlling under the allegations in the case at bar. In that case the alleged liability of the third party was based upon tort liability; whereas, in the instant action, the alleged liability of the third party is based upon contractual obligations. Therefore, the necessary pleadings as set forth in that case, which involved actionable negligence, are not controlling in the case at bar which involves contractual obligations.
The principle of subrogation is set forth in Boyd v. McKenney, 118 Okl. 8, 246 P. 406, wherein we held:
"The principle to be derived from the doctrine of subrogation is that it is born of equity and results from the natural justice of placing the burden where it ought to rest. It does not flow from any fixed rule of law, but rather from principles of justice, equity, and benevolence. It is a purely equitable result, depending like other equitable doctrines upon the facts and circumstances of each particular case to call it forth. It is a device adopted or invented by equity to compel the ultimate discharge of a debt or obligation by him, who, in good conscience, ought to pay it."
In 46 C.J.S. Insurance § 1209a(1) (b), at page 154, we find this language:
"* * * Insurer's right is derived from the rights which insured has, and is limited to those rights; and there can be no subrogation where insured had no claim against the third person, * * *.
* * * * * *
"Insurer's right to subrogation is not limited to cases where the liability of the third person is founded in tort, but any right of insured to indemnity will pass to insurer on payment of the loss, including rights under contracts with third persons, * * *."
In Standard Accident Insurance Co. v. Pellecchia, 15 N.J. 162, 104 A.2d 288, the Supreme Court of New Jersey said:
"In subrogation suits, based not on the torts of a third party but on his contractual obligation to the insured, there was some reluctance in the early decisions to permit any recovery. It is difficult to understand why any court that would permit subrogation against a tortfeasor should hesitate to allow subrogation based on a contractual *644 obligation of the defendant, for the assignment of tort claims was frowned upon at law while the assignment of choses in action and of many kinds of contracts was encouraged. It is now well settled generally that such an action in subrogation on the contractual obligation of the defendant to an insured exists in favor of the insurer. * * *"
In Consolidated Freightways, Inc. v. Moore, 38 Wash.2d 427, 229 P.2d 882, the Supreme Court of Washington said:
"That insurance company recoveries, under their right of subrogation, most often flow from tort actions is quite natural, but without significance. Subrogation is an equitable principle and applies to contract rights as fully as it does to tort actions."
The case of Maloney Tank Mfg. Co. v. Mid-Continent Petroleum Corporation, 10 Cir., 49 F.2d 146, involved an Oklahoma case wherein the tank company had an agreement with Mid-Continent to dismantle certain oil tanks. The tanks were destroyed by fire during the dismantling process. Mid-Continent was paid a certain sum by its insurance carrier to apply on the loss and they joined in an action to recover against the tank company. In affirming the judgment of the trial court against the tank company for an amount less than was paid by the insurance company to Mid-Continent, the Circuit Court of Appeals, Tenth Circuit, said that it was "* * * of the opinion that the action is one to recover for the failure to perform the work of dismantling the tanks in a workmanlike and careful manner," and considered it an action based on contractual obligations.
In Crude Oil Contracting Co. v. Insurance Co. of North America, 10 Cir., 118 F.2d 476, the insurance company recovered the amount against the contracting company which it was compelled to pay the insured for the loss of an oil storage tank in Oklahoma. The Circuit Court of Appeals, Tenth Circuit, in discussing the rights of the insurance company to recover, stated that aside from any question of negligence, contractual rights between the contracting company and the insured, would be a basis for recovery.
We can only conclude that an action in subrogation exists in favor of an insurance company against a third party, based on the contractual obligation of the third party to the insurance company's insured, where the insurance company has paid the claim of its insured for loss under the terms of a fire insurance policy; but the insurance company's rights are derived from the rights which the insured has and is limited to those rights, and there can be no subrogation where insured had no claim against the third party.
It necessarily follows that under the pleadings in the instant action, the insurance company is subrogated to all the rights that the insured had against the defendant.
It is well established that as against a demurrer, a petition must be liberally construed and all of its allegations of fact must be taken as true, together with all reasonable inferences therefrom, and if any fact stated therein entitled plaintiff to any relief, the demurrer should be overruled. See Wallace v. Williams, Okl., 313 P.2d 784.
Applying the above rule to the pleadings before us, we find the petition is sufficient to state a cause of action against the defendant. Whether the defendant would, or would not, have a defense on trial of the cause is not before us, as the sole question presented in determining whether the trial court erred in sustaining the demurrer to the petition is whether all the allegations, together with all reasonable inferences, entitled the insurer to any relief. We therefore conclude the trial court erred in sustaining the demurrer to insurer's amended petition and dismissing the action upon insurer's election to stand upon its amended petition.
Judgment of the trial court is reversed with directions to vacate its order dismissing *645 the action and order sustaining the demurrer to plaintiff's petition; reinstate the cause and take whatever action that may be necessary.
Judgment reversed with directions.
BLACKBIRD, C.J., HALLEY, V.C.J., and DAVISON, WILLIAMS and JACKSON, JJ., concur.
