This paper proposes a scheme for realization of a three-qubit Toffoli gate operation using three four-level atoms by a selective atom-field interaction in a cavity quantum electrodynamics system. In the proposed protocol, the quantum information is encoded on the stable ground states of atoms, and atomic spontaneous emission is negligible as the large atom-cavity detuning effectively suppresses the spontaneous decay of the atoms. The influence of the dissipation on fidelity and success probability of the three-qubit Toffoli gate is also discussed. The scheme can also be applied to realize an N-qubit Toffoli gate and the interaction time required does not rise with increasing the number of qubits.