We prove an integral surgery formula for framed instanton homology I♯(Ym(K)) for any knot K in a 3-manifold Y with [K]=0∈H1(Y;Q) and m=0. Though the statement is similar to Ozsváth-Szabó's integral surgery formula for Heegaard Floer homology, the proof is new and based on sutured instanton homology SHI and the octahedral lemma in the derived category. As a corollary, we obtain an exact triangle between I♯(Ym(K)), I♯(Ym+k(K)) and k copies of I♯(Y) for any m=0 and large k. In the proof of the formula, we discover many new exact triangles for sutured instanton homology and relate some surgery cobordism map to the sum of bypass maps, which are of independent interest. In a companion paper, we derive many applications and computations based on the integral surgery formula.