We present a new algorithm for classical simulation of quantum circuits over the Clifford þ T gate set. The runtime of the algorithm is polynomial in the number of qubits and the number of Clifford gates in the circuit but exponential in the number of T gates. The exponential scaling is sufficiently mild that the algorithm can be used in practice to simulate medium-sized quantum circuits dominated by Clifford gates. The first demonstrations of fault-tolerant quantum circuits based on 2D topological codes are likely to be dominated by Clifford gates due to a high implementation cost associated with logical T gates. Thus our algorithm may serve as a verification tool for near-term quantum computers which cannot in practice be simulated by other means. To demonstrate the power of the new method, we performed a classical simulation of a hidden shift quantum algorithm with 40 qubits, a few hundred Clifford gates, and nearly 50 T gates. DOI: 10.1103/PhysRevLett.116.250501 The path towards building a large-scale quantum computer will inevitably require verification and validation of small quantum devices. One way to check that such a device is working properly is to simulate it on a classical computer. This becomes impractical at some point because the cost of classical simulation typically grows exponentially with the size of a quantum system. With this fundamental limitation in mind it is natural to ask how well we can do in practice.Simulation methods which store a complete description of an n-qubit quantum state as a complex vector of size 2 n are limited to a small number of qubits n ≈ 30 − 40. For example, a state-of-the art implementation has been used to simulate Shor's factoring algorithm with 31 qubits and roughly half a million gates [1]. Using distributed computation it is possible to simulate 40 qubit circuits [2]. For certain restricted classes of quantum circuits it is possible to do much better [3][4][5][6][7]. Most significantly, the GottesmanKnill theorem allows efficient classical simulation of quantum circuits composed of gates in the so-called Clifford group [3]. In practice this allows one to simulate such circuits with thousands of qubits [1,4]. It also means that a quantum computer will need to use gates outside of the Clifford group in order to achieve useful speedups over classical computation. The full power of quantum computation can be recovered by adding a single non-Clifford gate to the Clifford group. A simple choice is the single-qubit T ¼ j0ih0j þ e iπ=4 j1ih1j gate. The Clifford þ T gate set obtained in this way is a natural instruction set for smallscale fault-tolerant quantum computers based on the surface code [8,9], and has been at the center of a recent renaissance in classical techniques for compiling quantum circuits [10][11][12].When it comes to realizing a logical (encoded) circuit, non-Clifford gates pose a serious challenge for any faulttolerant scheme based on 2D stabilizer codes [8,13] due to the lack of topological protection [14,15]. Such nonClifford gates can be imp...