Given a self-similar set K defined from an iterated function system Gamma = (gamma(1), ... , gamma(d)) and a set of functions H = {h(i) : K -> R}(d)(i=1) satisfying suitable conditions, we define a generalized gauge action on Kajiwara-Watatani algebras O-Gamma and their Toeplitz extensions T-Gamma. We then characterize the KMS states for this action. For each beta is an element of (0, infinity), there is a Ruelle operator L-H,L-beta, and the existence of KMS states at inverse temperature beta is related to this operator. The critical inverse temperature beta(c) is such that L-H,L-beta c has spectral radius 1. If beta < beta(c), there are no KMS states on O-Gamma and T-Gamma; if beta = beta(c), there is a unique KMS state on O-Gamma and T-Gamma which is given by the eigenmeasure of L-H,L-beta c; and if beta > beta(c), including beta = infinity, the extreme points of the set of KMS states on T-Gamma are parametrized by the elements of K and on O-Gamma by the set of branched points.