A finite element method formulation is developed for the solution of the anomalous diffusion equation. This equation belongs to the branch of mathematics called fractional calculus: it is governed by a partial differential equation in which a fractional time derivative, whose order ranges in the interval (0,1), replaces the first-order time derivative of the classical diffusion equation. In this work, the Caputo integro-differential operator is employed to represent the fractional time derivative. After assuming a linear time variation for the variable of interest, say u, in the intervals in which the overall time is discretized, the integral in the Caputo operator is computed analytically. To demonstrate the usefulness of the proposed formulation, four examples are analysed, showing a good agreement between the FEM results the analytical solutions, even for small orders of the time derivative.