The invasion of Spartina alterniflora is one of the main threats faced by mangrove wetlands in Quanzhou Bay, Fujian. To effectively manage S. alterniflora, mangrove plants (Kandelia obovata, Aegiceras corniculatum, Bruguiera gymnorhiza, Rhizophora stylosa, and Avicennia marina) were used to replace it in 2022 to restore the wetland ecosystem. Samples of meiofauna and marine nematodes were collected four times, including in September 2022 (before the removal of S. alterniflora), October 2022 (after removal), and December 2022 and March 2023 (after planting mangrove plants). This paper investigates changes in the composition, abundance, and biomass of meiofauna in different time periods, with a specific focus on comparing the community structure and biodiversity indices of marine nematodes in S. alterniflora and mangrove habitats. The results indicate that among the five meiofauna groups identified, marine nematodes account for 92.91%, 91.91%, 92.03%, and 85.92% of the total meiofauna abundance in the respective study periods. In the S. alterniflora habitat in September, marine nematodes were identified belonging to 12 families and 20 genera, of which 6 genera were dominant (percentage ≥ 5%). They were Ptycholaimellus, Parodontophora, Terschellingia, Halichoanolaimus, Metachromadora, and Parasphaerolaimus. In the mangrove habitat in December, marine nematodes were identified belonging to 15 families and 23 genera, with 6 genera being dominant, namely Daptonema, Admirandus, Parodontophora, Ptycholaimellus, Terschellingia, and Anoplostoma. Comparing the marine nematode communities in the two habitats, the mangrove habitat exhibits higher diversity than the S. alterniflora habitat. There was a change in the dominant genera, and their dominance has decreased. The dominant genera of marine nematodes found in both habitats are common and widely distributed groups. The changes in the abundance of meiofauna and the community structure of marine nematodes following the restoration of the S. alterniflora habitat by planting mangroves provide valuable insights for ecological monitoring after restoration measures in estuarine wetland conservation areas.