A spin 1/2 system on a honeycomb lattice is studied. The interactions between nearest neighbors are of XX, YY or ZZ type, depending on the direction of the link; different types of interactions may differ in strength. The model is solved exactly by a reduction to free fermions in a static Z2 gauge field. A phase diagram in the parameter space is obtained. One of the phases has an energy gap and carries excitations that are Abelian anyons. The other phase is gapless, but acquires a gap in the presence of magnetic field. In the latter case excitations are non-Abelian anyons whose braiding rules coincide with those of conformal blocks for the Ising model. We also consider a general theory of free fermions with a gapped spectrum, which is characterized by a spectral Chern number ν. The Abelian and non-Abelian phases of the original model correspond to ν = 0 and ν = ±1, respectively. The anyonic properties of excitation depend on ν mod 16, whereas ν itself governs edge thermal transport. The paper also provides mathematical background on anyons as well as an elementary theory of Chern number for quasidiagonal matrices.