We develop a gyrokinetic treatment for ions in the magnetic presheath, close to the plasma-wall boundary. We focus on magnetic presheaths with a small magnetic field to wall angle, a << 1 (in radians). Characteristic lengths perpendicular to the wall in such a magnetic presheath scale with the typical ion Larmor orbit size, ri. The smallest scale length associated with variations parallel to the wall is taken to be across the magnetic field, and ordered l = ri d, where d << 1 is assumed. The scale lengths along the magnetic field line are assumed so long that variations associated with this direction are neglected. These orderings are consistent with what we expect close to the divertor target of a tokamak. We allow for a strong component of the electric field E in the direction normal to the electron repelling wall, with strong variation in the same direction. The large change of the electric field over an ion Larmor radius distorts the orbit so that it is not circular. We solve for the lowest order orbits by identifying coordinates, which consist of constants of integration, an adiabatic invariant and a gyrophase, associated with periodic ion motion in the system with a = d = 0. By using these new coordinates as variables in the limit a ~ d << 1, we obtain a generalised ion gyrokinetic equation. We find another quantity that is conserved to first order and use this to simplify the gyrokinetic equation, solving it in the case of a collisionless magnetic presheath. Assuming a Boltzmann response for the electrons, a form of the quasineutrality equation that exploits the change of variables is derived. The gyrokinetic and quasineutrality equations give the ion distribution function and electrostatic potential in the magnetic presheath if the entrance boundary condition is specified.