We study random surfaces which arise as height functions of random perfect matchings (. dimer conﬁgurations) on a weighted, bipartite, doubly periodic graph G embedded in the plane. We derive explicit formulas for the surface tension and local Gibbs measure probabilities of these models. The answers involve a certain plane algebraic curve, which is the spectral curve of the Kasteleyn operator of the graph. For example, the surface tension is the Legendre dual of the Ronkin function of the spectral curve. The amoeba of the spectral curve represents the phase diagram of the dimer model. .