In this paper, we present a new kind of fractional dynamical equations, i.e. the fractional generalized Hamiltonian equations, and study variation equations and the method of the construction of integral invariants of the system. Based on the definition of Riemann–Liouville fractional derivatives, fractional generalized Hamiltonian equations and its variation equations are established. Then, the relation between first integral and integral invariant of the system is studied, and it is proved that, using a first integral, we can construct an integral invariant of the system. As deductions of above results, a construction method of integral invariants of a traditional generalized Hamiltonian system are given. Further, one example of fractional generalized Hamiltonian system is given to illustrate the method and results of the application. Finally, we study the first integral and integral invariant of the Euler equation of a rigid body which rotates with respect to a fixed-point.