The graphene/MoS2 heterojunction formed by joining the two components laterally in a single plane promises to exhibit a low-resistance contact according to the Schottky-Mott rule. Here we provide an atomic-scale description of the structural, electronic, and magnetic properties of this type of junction. We first identify the energetically favorable structures in which the preference of forming C-S or C-Mo bonds at the boundary depends on the chemical conditions. We find that significant non-carrier related charge transfer between graphene and undoped MoS2 is localized at the boundary. We show that the abundant 1D boundary states substantially pin the Fermi level in the lateral contact between graphene and MoS2, in close analogy to the effect of 2D interfacial states in the contacts between 3D materials. Furthermore, we propose specific ways in which these effects can be exploited to achieve spin-polarized currents.