
906 So.2d 1117 (2005)
Amado Evarito GARCIA, Appellant,
v.
Renee STEWART, Woodgate Condominium Association, Inc., John Tenant and Jane Tenant, Appellees.
No. 4D04-1836.
District Court of Appeal of Florida, Fourth District.
May 25, 2005.
Opinion Denying Rehearing July 27, 2005.
*1119 Brenda Cox of Schilian, Watarz & Cox, P.A., Boca Raton, for appellant.
Ronald E. D'Anna and Jennifer J. Kramer of McClosky, D'Anna, Ioannou & Dieterle, LLP, Boca Raton, for appellees.
GROSS, J.
The former owner of a condominium unit, Amado Garcia, appeals from an order denying his motion attacking an order that disbursed surplus funds generated by a foreclosure sale of his unit arising from a second mortgage.
We reverse, holding that the circuit court lacked jurisdiction to distribute the funds to the holder of a lien superior to the second mortgage, after the lienholder had been dismissed as a party in the final judgment of foreclosure.
Appellee Woodgate Condominium Association recorded a claim of lien against Garcia's unit for assessments, attorney's fees, and costs in the amount of $1,170.20.
Later, Renee Stewart, the holder of a second mortgage, filed a foreclosure complaint against Garcia. The suit named the Association as a defendant because of its claim of lien. The Association's answer raised the defense that its lien was superior to Stewart's mortgage. Garcia defaulted. The final foreclosure judgment dismissed the Association as a defendant, ruling that "[i]ts lien [was] superior to" that of Stewart.
A third party purchased the property at a foreclosure sale. After distributing money *1120 to Stewart to satisfy her second mortgage, the clerk of the court deposited an excess of $17,794.83 into the court registry.
On March 11, 2003, the Association moved for payment of the surplus from the foreclosure sale. The Association's attorney filed an affidavit of the amount due, based on his "review of the records of the Association." The affidavit claimed arrearages of $3,580.20 for past due assessments and late charges, attorney's fees and costs of $6,119.77, and $6,675.60 for a "special restoration assessment" ratified after Stewart filed her foreclosure complaint.
On March 26, 2003, the trial court granted the Association's motion and ordered the distribution of $16,375.57 from the court registry to the Association's attorney.
On October 28, 2003, Garcia filed a motion attacking the March 26 order, which in essence was a motion filed under Florida Rule of Civil Procedure 1.540(b). The trial court denied the motion on April 8, 2004.
We begin by discussing the dismissal of the Association as a party defendant in the final judgment of foreclosure. Dismissal was legally correct because the Association's lien was superior to Stewart's second mortgage. The general rule is "`that persons holding mortgages or liens prior to the mortgage under foreclosure are neither necessary nor proper parties to the action.'" Cone Bros. Constr. Co. v. Moore, 141 Fla. 420, 193 So. 288, 290 (1940) (citation omitted); Poinciana Hotel of Miami Beach, Inc. v. Kasden, 370 So.2d 399, 400 n. 5 (Fla. 3d DCA 1979). The supreme court has explained that a "prior mortgagee may elect for himself the time and manner of enforcing his security. He cannot be compelled to be a party to a suit by a junior encumbrancer foreclosing his lien." Cone Bros., 193 So. at 290.
The rationale behind the rule is that "[f]oreclosure does not terminate interests in the foreclosed real estate that are senior to the mortgage being foreclosed." Conversion Prop., L.L.C. v. Kessler, 994 S.W.2d 810, 813 (Tex.Ct.App.1999); Armand's Eng'g, Inc. v. Town & Country Club, Inc., 113 R.I. 515, 324 A.2d 334, 338 (1974). The Texas Court of Appeals has explained the dynamics of a junior lien foreclosure sale:
[T]he successful bidder at a junior lien foreclosure takes title subject to the prior liens. The purchaser takes the property charged with the primary liability for the payment of the prior mortgage and must therefore service the prior liens to prevent loss of the property by foreclosure of the prior liens. Consequently, as a practical matter, a prospective purchaser usually will subtract the amount of any outstanding senior liens from the fair market value of the property in calculating its foreclosure bid.
Conversion Prop., 994 S.W.2d at 813 (citation omitted). Unlike a junior lienholder's security interest which is "transferred from the property to the fund that stands in the place of the property," see Household Finance Services v. Bank of America, 883 So.2d 346, 348 (Fla. 4th DCA 2004), a senior lienholder's security interest remains with the property even after the foreclosure sale. See Cone Bros., 193 So. at 290.
"After a foreclosure sale, the trial court is required to prioritize the interests of the competing junior lienholders and the amounts due each." Citibank, FSB v. PNC Mortgage Corp., 718 So.2d 300, 302 (Fla. 2d DCA 1998); United States v. Sneed, 620 So.2d 1093, 1094 (Fla. 1st DCA 1993). "[A]ny surplus remaining after a foreclosure sale should be paid to the junior lienholders in accordance with the priority of their liens on the property...." *1121..." Gen. Bank, F.S.B. v. Westbrooke Pointe, Inc., 548 So.2d 736 (Fla. 3d DCA 1989). Only after such liens "have been satisfied may any surplus be disbursed to the owner of the equity of redemption." Id.; see Asher Perlin, et al., Disbursement of Surplus Proceeds from a Foreclosure Sale  The Urban Myth of the Race to the Courthouse, 78 Fla. B.J. 45 (July/Aug.2004).
Because senior lienors' rights are unaffected by foreclosure, holders of liens which are senior in priority have no right to share in a surplus produced by the foreclosure of a junior mortgage. As explained in the RESTATEMENT (THIRD) OF PROPERTY:
When the foreclosure sale price exceeds the amount of the mortgage obligation, the surplus is applied to liens and other interests terminated by the foreclosure in order of their priority and the remaining balance, if any, is distributed to the holder of the equity of redemption.
RESTATEMENT (THIRD) OF PROP.: MORTGAGES § 7.4 (1997). A comment to this section explains that since a senior lienholder's security interest is not "terminated" by foreclosure of a junior lien, it is not entitled to share in a surplus fund:
Senior lienors have no lien claim to a surplus produced by the foreclosure of a junior mortgage. Unlike their junior lien counterparts, their liens are unaffected by foreclosure and remain on the foreclosed real estate. They remain free to foreclose on the real estate, and thus there is no justification for transferring any part of their liens to the junior foreclosure surplus. This is true even where obligations secured by senior liens are in default.
RESTATEMENT (THIRD) OF PROP.: MORTGAGES § 7.4 cmt. c. Courts in other states follow the Restatement. See Davis v. Huntsville Prod. Credit Ass'n., 481 So.2d 1103, 1106 (Ala.1985) ("A first mortgagee has no right to any surplus upon foreclosure of the second mortgage, particularly in the absence of default of the first mortgage."); Bohra v. Montgomery, 31 Ark.App. 253, 792 S.W.2d 360, 362 (1990) ("On foreclosure of a junior mortgage, a senior encumbrancer who was not made a party, and for whom no provision was made in the decree, has no claim on the proceeds of a sale of the property under the foreclosure, since ... the foreclosure of a junior mortgage has no affect on the rights of a senior lien.") (citation omitted); Thomas v. Haines, 285 Mass. 90, 188 N.E. 621, 623 (1934) ("[P]rior mortgages and liens do not carry a right in law or equity to any excess received in foreclosure of a subsequent mortgage"); Armand's Eng'g, 324 A.2d at 337; Conversion Prop., 994 S.W.2d at 813-14.
The purchaser at the foreclosure sale was "jointly and severally liable" with Garcia for "all unpaid assessments that came due up to the time of transfer of title." § 718.116(1)(a), Fla. Stat. (2004). After its dismissal from the foreclosure suit, the Association retained the right to protect its interest by initiating foreclosure proceedings against the real estate or bringing "an action to recover a money judgment for the unpaid assessments." § 718.116(6)(a).
Even though Garcia is correct that the trial court erred in ordering disbursement to the Association,[1] he must demonstrate entitlement to challenge the order under rule 1.540, because he served his motion long after the ten-day limit for a *1122 motion for rehearing and did not timely appeal the March 26, 2003 ruling. See Fla. R. Civ. P. 1.530(b); Sullivan v. Malden Trust Co., 632 So.2d 223, 223-24 (Fla. 2d DCA 1994) (holding that once the time limitations for rehearing and notice of appeal have run, a party seeking to set aside a judgment can proceed only under rule 1.540).
Rule 1.540 provides relief from judgments only "under a limited set of circumstances." See Abram v. Wolicki, 864 So.2d 18, 20 (Fla. 4th DCA 2003) (citation omitted). A substantive legal error is not one of the "limited circumstances" that can sustain a request for relief from judgment under rule 1.540. See Curbelo v. Ullman, 571 So.2d 443, 445 (Fla.1990) ("[A] judicial error such as a `mistaken view of the law' is not one of the circumstances contemplated by the rule.").
Rule 1.540(b)(4) permits a court to "relieve" a party from a final "judgment, decree, order or proceeding" if "the judgment or decree is void." See, e.g., Greisel v. Gregg, 733 So.2d 1119, 1121 (Fla. 5th DCA 1999) (citation omitted). Because the trial court was without subject matter jurisdiction when it entered the order distributing funds, the order was void and Garcia was entitled to have it set aside.
In general, there are two aspects to a court's subject matter jurisdiction. The first concept "concerns the power of the trial court to deal with the class of cases to which a particular case belongs." Paulucci v. Gen. Dynamics Corp., 842 So.2d 797, 801 n. 3 (Fla.2003) (citation omitted). The second aspect requires that a court's jurisdiction be lawfully invoked by the filing of a proper pleading. See Fla. Power & Light v. Canal Auth., 423 So.2d 421, 423 (Fla. 5th DCA 1982). As the supreme court has explained:
[B]efore this potential jurisdiction of the subject-matter  this power to hear and determine  can be exercised, it must be lawfully invoked and called into action; the parties and the subject-matter of the particular case must be brought before the court in such a way that it acquires the jurisdiction and the power to act. There must be a right in dispute between two or more parties; a proceeding commenced under the proper rules of law; process must be served on the opposite party or parties in order that they may have an opportunity to be heard ... The jurisdiction and power of a court remain at rest until called into action by some suitor; it cannot by its own action institute a proceeding sua sponte. The action of a court must be called into exercise by pleading and process, prescribed or recognized by law, procured or obtained by some suitor by filing a declaration, complaint, petition, cross-bill, or in some form requesting the exercise of the power of the court. If a court should render a judgment in a case where it had jurisdiction of the parties, upon a matter entirely outside of the issues made, it would, of necessity, be arbitrary and unjust as being outside the jurisdiction of the subject-matter of the particular case, and such judgment would be void and would not withstand a collateral attack, for upon such matter a presumption would arise that the parties had had no opportunity to be heard.
Lovett v. Lovett, 93 Fla. 611, 112 So. 768, 775-76 (1927) (emphasis added); see Lockwood v. Pierce, 730 So.2d 1281, 1283 (Fla. 4th DCA 1999); In re Estate of Hatcher, 439 So.2d 977, 980 (Fla. 3d DCA 1983).
In this case, before or after its dismissal from the case, the Association filed no pleading concerning its claim of lien. Section 718.116(6)(a) contemplates two possible actions the Association might have pursued  "an action to foreclose a lien for assessments" and "an action to recover a money judgment." The Association had *1123 the legal right to collect unpaid assessments from Garcia; however, the Association did not file a pleading to commence a proceeding to advance its right to recovery.
For subject matter jurisdiction purposes, Lovett identifies "pleadings" as a "declaration, complaint, petition, [or] cross-bill." 112 So. at 775-76; Hatcher, 439 So.2d at 980 n. 2. Under the current rules of civil procedure, "pleadings" sufficient to invoke a court's jurisdiction include a complaint, petition, counterclaim, crossclaim, and third-party complaint. Fla. R. Civ. P. 1.100(a). In Green v. Sun Harbor Homeowners' Association, Inc., 730 So.2d 1261, 1263 (Fla.1998), the supreme court relied upon rule 1.100(a) to hold that while "[c]omplaints, answers, and counterclaims are pleadings," a "motion to dismiss is not."
Similarly, the Association's post judgment motion to disburse funds, filed after it had been dismissed as a defendant in the lawsuit, was not a pleading sufficient to invoke the jurisdiction of the court to adjudicate its right to the funds. The trial court was therefore without jurisdiction to disburse the funds so that its order disbursing the funds was void. See Lovett, 112 So. at 776; Defreitas v. Defreitas, 398 So.2d 991, 992 (Fla. 4th DCA 1981); Bartolucci v. McKay, 428 So.2d 378, 379 (Fla. 5th DCA 1983). A void final order or judgment may be attacked under rule 1.540(b).
Because the March 26, 2003 order was void, we reverse the April 8, 2004 order denying the motion to set aside that order. On remand, the circuit court shall order the funds disbursed by that order to be redeposited into the court registry.
Reversed and remanded.
STEVENSON and SHAHOOD, JJ., concur.

ON MOTION FOR REHEARING
GROSS, J.
The Association's motion for rehearing has called our attention to additional facts that were not previously made a part of the record. The facts pertain to the Association's participation in a separate circuit court lawsuit involving the foreclosure of a first mortgage on the property. These additional facts do not change the result in this case. Even though the Association filed a lien foreclosure cross-claim in the other lawsuit, Garcia still had the right to challenge the disbursement of funds in this action through a rule 1.540(b) motion.
There were two mortgages on Garcia's property. The holder of the first mortgage was M & T Mortgage Corp. The holder of the second mortgage, which was at issue in this case, was Renee Stewart.
M & T filed a mortgage foreclosure action in March, 2002, naming Garcia and the Association as defendants. The M & T action was assigned to Judge Lynch. The Association answered the M & T action and filed a cross-claim against Garcia seeking foreclosure on its claim of lien. Garcia filed no responsive pleading in the M & T action.
The following month, Stewart filed a second foreclosure suit to foreclose her second mortgage. The Stewart action was assigned to Judge Burnstein under a different case number than the M & T action. The Association filed an answer in the Stewart action, but Garcia filed no responsive pleading.
M & T acquired a summary final judgment against Garcia from Judge Lynch on July 14 of that year; Stewart acquired a default final judgment from Judge Burnstein on July 18. Although the Association secured a default against Garcia on its lien foreclosure claim in the M & T action, it never obtained a final judgment. In the *1124 Stewart action, Judge Burnstein dismissed the Association as a defendant in the final judgment of foreclosure.
The foreclosure sale in the Stewart action occurred on February 10, 2003; there had not yet been a foreclosure sale in the M & T action. The buyer was Escala Homes & Mortgages. On February 21, after the clerk paid off the junior lienholders and issued a certificate of title to Escala, a surplus remained in the court registry. Escala moved to intervene in the M & T action, explaining that it had recently purchased the property in the Stewart action foreclosure sale and that it was willing to pay off M & T's first mortgage.
On March 20, 2003, the Association secured an order from Judge Lynch, the M & T action judge, disbursing the proceeds from the Stewart action, the case presided over by Judge Burnstein, from which the Association had been dismissed as a party.
Based on these new facts, the Association argues that the panel's opinion incorrectly assumed that the "Association filed no pleading concerning its claim of lien." The non-existence of a pleading in this case was significant, because it went to Garcia's entitlement to challenge the disbursement order under rule 1.540. However, that critical fact remains unchanged because the pleadings the Association filed were in a separate lawsuit. We are aware of no rule of procedure or administrative order that authorized the trial judge in the M & T action to reach over into a different lawsuit, before a different judge, and enter an order disbursing funds in that case to a party that had been dismissed by a final judgment. This is not a case where the Association had secured a final judgment in the M & T action and was pursuing some post-judgment remedy. The existence of the Association's pleadings in the M & T action did not affect Garcia's right to attack the March 26, 2003 order in the Stewart action under rule 1.540(b)(4).
The Association's motion for rehearing is denied.
STEVENSON, C.J., and SHAHOOD, J., concur.
NOTES
[1]  Another legal error that occurred was that the trial court disbursed surplus funds without setting an evidentiary hearing. See D.A.D., Inc. v. Poole, 407 So.2d 1072, 1073 (Fla. 4th DCA 1981); Schroth v. Cape Coral Bank, 377 So.2d 50, 51 (Fla. 2d DCA 1979).
