A rotary engine, including: a stator assembly, including an intake stator and an exhaust stator, the intake stator and the exhaust stator each including an annular guiding groove, the annular guiding groove of the intake stator and the annular guiding groove of the exhaust stator axially corresponding to each other and defining a track, the intake stator further including an annular intake groove, the exhaust stator further including an annular exhaust groove; a rotor, rotatably disposed between the intake stator and the exhaust stator, including a plurality of cylinders and a plurality of cylinder heads, each of the plurality of cylinders being covered by one of the plurality of cylinder heads, each of the plurality of cylinder heads including an intake port and an exhaust port, the intake port being connected to the annular intake groove, the exhaust port being connected to the annular exhaust groove; a shaft, inserted axially in the stator assembly and the rotor; a plurality of valve mechanisms, posited on the plurality of cylinder heads respectively and each including an intake valve configured to selectively close the intake port and an exhaust valve configured to selectively close the exhaust port; a plurality of pistons, received in the plurality of cylinders respectively and each including a piston rod which projects radially beyond one of the plurality of cylinders and is movable along the track, an intake starting point, a compression starting point, a power starting point and an exhaust starting point of each of the plurality of pistons being sequentially defined relatively based on the track; and a plurality of spark plugs, posited on the plurality of cylinder heads and exposed to interiors of the plurality of cylinders, respectively; characterized in that the annular intake groove and the annular exhaust groove extend annularly around the shaft and annularly around the track; and each of the plurality of valve mechanisms further includes a valve stem assembly which is resiliently posited on the cylinder head and includes a roller abutted against the stator assembly, and when the roller moves with the rotor and is urged by a raise (171, 172, 17A) posited on an outer circumferential surface of the stator assembly, the valve mechanism is driven to open. a stator assembly, including an intake stator and an exhaust stator, the intake stator and the exhaust stator each including an annular guiding groove, the annular guiding groove of the intake stator and the annular guiding groove of the exhaust stator axially corresponding to each other and defining a track, the intake stator further including an annular intake groove, the exhaust stator further including an annular exhaust groove; a rotor, rotatably disposed between the intake stator and the exhaust stator, including a plurality of cylinders and a plurality of cylinder heads, each of the plurality of cylinders being covered by one of the plurality of cylinder heads, each of the plurality of cylinder heads including an intake port and an exhaust port, the intake port being connected to the annular intake groove, the exhaust port being connected to the annular exhaust groove; a shaft, inserted axially in the stator assembly and the rotor; a plurality of valve mechanisms, posited on the plurality of cylinder heads respectively and each including an intake valve configured to selectively close the intake port and an exhaust valve configured to selectively close the exhaust port; a plurality of pistons, received in the plurality of cylinders respectively and each including a piston rod which projects radially beyond one of the plurality of cylinders and is movable along the track, an intake starting point, a compression starting point, a power starting point and an exhaust starting point of each of the plurality of pistons being sequentially defined relatively based on the track; and a plurality of spark plugs, posited on the plurality of cylinder heads and exposed to interiors of the plurality of cylinders, respectively; characterized in that the annular intake groove and the annular exhaust groove extend annularly around the shaft and annularly around the track; and each of the plurality of valve mechanisms further includes a valve stem assembly which is resiliently posited on the cylinder head and includes a roller abutted against the stator assembly, and when the roller moves with the rotor and is urged by a raise (171, 172, 17A) posited on an outer circumferential surface of the stator assembly, the valve mechanism is driven to open.