Whenever the state of New Jersey has any lien or encumbrance upon real property and an action arising out of a prior lien or encumbrance on the same real property is instituted to foreclose, strictly foreclose, or re-foreclose the said prior lien or encumbrance, or otherwise to affect the lien or encumbrance of the state, or when such action is brought to foreclose the equity of redemption of the real property after a sale for unpaid taxes or other municipal liens, the lien or encumbrance of the state and its priority may be brought in question and definitely settled by the court having jurisdiction of the matter.
N.J.S. § 2A:45-1