The paper studies the relationship between logic programs with the stable model semantics and difference logic recently considered in the Satisfiability Modulo Theories framework. Characterizations of stable models in terms of level rankings are developed building on simple linear integer constraints allowed in difference logic. Based on a characterization with level rankings a translation is devised which maps a normal program to a difference logic formula capturing stable models of the program as satisfying valuations of the resulting formula. The translation makes it possible to use a solver for difference logic to compute stable models of logic programs.