In Ref [1] we have presented the results of an exploratory lattice QCD computation of the long-distance contribution to the $K^+topi^+ ubar{ u}$ decay amplitude. In the present paper we describe the details of this calculation, which includes the implementation of a number of novel techniques. The $K^+topi^+ ubar{ u}$ decay amplitude is dominated by short-distance contributions which can be computed in perturbation theory with the only required non-perturbative input being the relatively well-known form factors of semileptonic kaon decays. The long-distance contributions, which are the target of this work, are expected to be of O(5%) in the branching ratio. Our study demonstrates the feasibility of lattice QCD computations of the $K^+topi^+ ubar{ u}$ decay amplitude, and in particular of the long-distance component. Though this calculation is performed on a small lattice ($16^3times32$) and at unphysical pion, kaon and charm quark masses, $m_pi=420$ MeV, $m_K=563$ MeV and $m_c^{overline{mathrm{MS}}}(mbox{2 GeV})=863$ MeV, the techniques presented in this work can readily be applied to a future realistic calculation.