A measurement of the phase difference between the short- and long-distance contributions to the B+→K+μ+μ- decay is performed by analysing the dimuon mass distribution. The analysis is based on pp collision data corresponding to an integrated luminosity of 3fb-1 collected by the LHCb experiment in 2011 and 2012. The long-distance contribution to the B+→K+μ+μ- decay is modelled as a sum of relativistic Breit–Wigner amplitudes representing different vector meson resonances decaying to muon pairs, each with their own magnitude and phase. The measured phases of the J/ ψ and ψ(2 S) resonances are such that the interference with the short-distance component in dimuon mass regions far from their pole masses is small. In addition, constraints are placed on the Wilson coefficients, C9 and C10, and the branching fraction of the short-distance component is measured.