Kasteleyn stated that the generating function of the perfect matchings of a graph of genus g may be written as a linear combination of 4g Pfaffians. Here we prove this statement. As a consequence we present a combinatorial way to compute the permanent of a square matrix. Mathematical Reviews Subject Numbers 05B35, 05C15, 05A15 Supported by NATO-CNR Fellowship Supported by DONET, GACR 0194 and GAUK 194 1