Consider a higher rank graph of rank k. Both the Cuntz-Krieger algebra and Toeplitz-Cuntz-Krieger algebra of the graph carry natural gauge actions of the torus Tk, and restricting these guage actions to one parameter subgroups of Tk gives dynamical systems involving actions of the real line. We study the KMS states of these dynamical systems. We find that for large inverse temperatures B, the simplex of KMS B states of the Toeplitz-Cuntz-Krieger algebra has dimension d one less than the number of vertices in the graph. We also show that there is a preferred dynamics for which there is a critical inverse temperature Bc: for B larger than Bc, there is a d-dimensional simplex of KMS states; when B=Bc and one parameter subgroup is dense, there is a unique KMS state, and this state factors through the Cuntz-Krieger algebra. As in previous studies for k=1, our main tool is the Perron-Frobenius theory for irreducible non-negative matrices, though here we need a version of the theory for commuting families of matrices.