The promise of tremendous computational power, coupled with the development of robust error-correcting schemes, has fuelled extensive efforts to build a quantum computer. The requirements for realizing such a device are confounding: scalable quantum bits (two-level quantum systems, or qubits) that can be well isolated from the environment, but also initialized, measured and made to undergo controllable interactions to implement a universal set of quantum logic gates. The usual set consists of single qubit rotations and a controlled-NOT (CNOT) gate, which flips the state of a target qubit conditional on the control qubit being in the state 1. Here we report an unambiguous experimental demonstration and comprehensive characterization of quantum CNOT operation in an optical system. We produce all four entangled Bell states as a function of only the input qubits' logical values, for a single operating condition of the gate. The gate is probabilistic (the qubits are destroyed upon failure), but with the addition of linear optical quantum non-demolition measurements, it is equivalent to the CNOT gate required for scalable all-optical quantum computation.