Quantum information science addresses how the processing and transmission of information are affected by uniquely quantum mechanical phenomena. Combination of two-qubit gates has been used to realize quantum circuits, however, scalability is becoming a critical problem. The use of three-qubit gates may simplify the structure of quantum circuits dramatically. Among them, the controlled-SWAP (Fredkin) gates are essential since they can be directly applied to important protocols, e.g., error correction, fingerprinting, and optimal cloning. Here we report a realization of the Fredkin gate for photonic qubits. We achieve a fidelity of 0.85 in the computational basis and an output state fidelity of 0.81 for a 3-photon Greenberger-Horne-Zeilinger state. The estimated process fidelity of 0.77 indicates that our Fredkin gate can be applied to various quantum tasks.