In September 2010, the plaintiff commenced this action for declaratory and injunctive relief against, among others, the Town of Woodbury and the Village of Woodbury. The Town and the Village separately moved pursuant to CPLR 3211 (a) to dismiss the complaint insofar as asserted against each of them, inter alia, on the ground of lack of standing. Thereafter the plaintiff moved, among other things, for leave to amend the complaint to substitute Zigmond Brach as the plaintiff and add two causes of action. In an order dated November 15, 2011, the Supreme Court granted the motions of the Town and the Village on the ground that the plaintiff lacked standing to commence the action. In another order, also dated November 15, *7552011, the Supreme Court denied, the plaintiffs motion because “the original complaint is dismissed.”
Under the circumstances presented herein, the Supreme Court should have decided, on the merits, that branch of the plaintiffs motion which was for leave to amend the complaint before the court decided the motions of the Town and the Village to dismiss the complaint (see generally Cooke-Garrett v Hoque, 109 AD3d 457 [2013]). Leave to amend a pleading should be freely given absent prejudice or surprise to the opposing party, unless the proposed amendment is palpably insufficient or patently devoid of merit (see CPLR 3025 [b]; Carroll v Motola, 109 AD3d 629 [2013]; Finkelstein v Lincoln Natl. Corp., 107 AD3d 759, 761 [2013]; Lucido v Mancuso, 49 AD3d 220, 227 [2008]). Moreover, a court shall not examine the legal sufficiency or merits of a pleading unless such insufficiency or lack of merit is clear and free from doubt (see Lucido v Mancuso, 49 AD3d at 227). Here, the proposed amended complaint, which principally sought to shift the claims from the plaintiff to a party who could have asserted those claims in the first instance, is proper, since “such an amendment, by its nature, did not result in surprise or prejudice to the [defendants], who had prior knowledge of the claimfs] and an opportunity to prepare a proper defense” (Fulgum v Town of Cortlandt Manor, 19 AD3d 444, 446 [2005]; see JCD Farms v Juul-Nielsen, 300 AD2d 446 [2002]; New York State Thruway Auth. v CBE Contr. Corp., 280 AD2d 390 [2001]). In addition, the proposed amended complaint was not palpably insufficient or patently devoid of merit.
Accordingly, that branch of the plaintiffs motion which was for leave to serve an amended complaint should have been granted. Additionally, since the proposed amended complaint rectified the plaintiff’s lack of standing, the Supreme Court should not have granted the motions to dismiss the complaint on the basis of lack of standing. Dillon, J.P., Dickerson, Austin and Sgroi, JJ., concur.