Whenever any attorney-at-law performs any legal services for the plaintiff, at the request or instance of any person interested in lands or land claims, or any part thereof, in any court which may be held in this state, either federal or state, for the purpose of confirming, quieting or establishing the title of any tract of land and it shall be agreed or it has been agreed, between such attorney and such person so interested, that such attorney shall represent the plaintiff and receive for such services any part or portion of such land, such attorney may directly institute suit against all the owners of such tract of land, known or unknown, to establish his right and title in him under said agreement to the part or portion of such land agreed to be paid to him for his services; or he may in any suit brought to quiet the title to such tract of land or any part thereof, thereafter, or to partition the same, or both, intervene and set up his claim therein for the part of such land so agreed to be paid him for his services, and it shall be the duty of the court in all such cases to decide in such suit or intervention, and if it be found that there was such an agreement, made by such person owning or interested in such lands, or any part thereof, and acting in whole or in part for the plaintiff or any of them, and also that the services were worth, according to the usual charges in this state for such service, at the time they were rendered, or agreed to be rendered, the amount so agreed to be paid for the same to adjudge or decree the amount so agreed to be paid for such services out of the lands involved in the suit or proceedings, as his property. And the same may be partitioned or set apart to him, in any partition suit then pending, or which may thereafter be pending; or if the court should find that the amount so agreed to be paid exceeds the value of the services in this state at the time they were rendered or contracted for, then the court shall allow or adjudge or decree to such attorney an amount of such land as compensation for his services as will be reasonable as aforesaid.
NMS § 42-6-10