By harnessing the superposition and entanglement of physical states, quantum computers could outperform their classical counterparts in solving problems of technological impact, such as factoring large numbers and searching databases. A quantum processor executes algorithms by applying a programmable sequence of gates to an initialized register of qubits, which coherently evolves into a final state containing the result of the computation. Simultaneously meeting the conflicting requirements of long coherence, state preparation, universal gate operations, and qubit readout makes building quantum processors challenging. Few-qubit processors have already been shown in nuclear magnetic resonance, cold ion trap and optical systems, but a solid-state realization has remained an outstanding challenge. Here we demonstrate a two-qubit superconducting processor and the implementation of the Grover search and Deutsch-Jozsa quantum algorithms. We employ a novel two-qubit interaction, tunable in strength by two orders of magnitude on nanosecond time scales, which is mediated by a cavity bus in a circuit quantum electrodynamics (cQED) architecture. This interaction allows generation of highly-entangled states with concurrence up to 94%. Although this processor constitutes an important step in quantum computing with integrated circuits, continuing efforts to increase qubit coherence times, gate performance and register size will be required to fulfill the promise of a scalable technology.