Integrated quantum photonics is an appealing platform for quantum information processing, quantum communication and quantum metrology. In all these applications it is necessary not only to be able to create and detect Fock states of light but also to program the photonic circuits that implements some desired logical operation. Here we demonstrate a reconfigurable controlled two-qubit operation on a chip using a multiwaveguide interferometer with a tunable phase shifter. We find excellent agreement between theory and experiment, with a 0.98 pm 0.02 average similarity between measured and ideal operations.