A phosphorus and nitrogen-containing epoxy resin flame retardant curing agent and its preparation method, relating to a chemical curing agent and its preparation method, the preparation raw materials include: phosphorus oxychloride, 1-oxyphospha-4-hydroxymethyl ‑2,6,7‑trioxabicyclo[2.2.2]octane and m-xylylenediamine, the method for preparing the flame retardant is divided into two steps, the first step, phosphorus oxychloride (POCl3 ) and 1-oxygen phospha-4-hydroxymethyl-2,6,7-trioxabicyclo [2.2.2] octane (PEPA) react under certain conditions to generate a phosphorus-containing intermediate; the second step, The intermediate obtained in the first step is stirred and reacted with m-xylylenediamine under the introduction of an inert gas for a certain period of time, and the product is filtered, washed, dried, etc. to obtain a white solid. The compound has good compatibility with epoxy resin, can be cured together with epoxy resin, and has little influence on the mechanical properties of the cured product. It can be used as a curing agent for epoxy resin, and can effectively improve the flame retardant properties.