We compute the two loop coefficient in the relation between the lattice bare coupling and the running coupling defined through the Schroedinger functional for the case of pure SU(2) gauge theory. This result is needed as one computational component to relate the latter to the MSbar-coupling, and it allows us to implement O(a) improvement of the Schroedinger functional to two-loop order. In addition, the two-loop beta-function is verified in a perturbative computation on the lattice, and the behavior of an improved bare coupling is investigated beyond one loop.