  We prove an integral surgery formula for framed instanton homology
$I^\sharp(Y_m(K))$ for any knot $K$ in a $3$-manifold $Y$ with $[K]=0\in
H_1(Y;\mathbb{Q})$ and $m\neq 0$. Though the statement is similar to
Ozsv\'ath-Szab\'o'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^\sharp(Y_m(K))$, $I^\sharp(Y_{m+k}(K))$ and $k$ copies of
$I^\sharp(Y)$ for any $m\neq 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.
