We determined the K band luminosity function (LF) of cluster galaxies at redshift z~1.2, using near-infrared images of three X-ray luminous clusters at z=1.11,1.24,1.27. The composite LF was derived down to M*+4, by means of statistical background subtraction, and is well described by a Schechter function with K*=20.5 AB mag and alpha=-1. From the K band composite LF we derived the stellar mass function of cluster galaxies. Using available X-ray mass profiles we determined the M/L ratios of these three clusters, which tend to be lower than those measured in the local universe. With these data, no significant difference can be seen between the shapes of the cluster galaxies LF and the LF of field galaxies at similar redshift. We also found no significant evolution out to z ~1.2 in the bright (<M*+4) part of the cluster galaxies LF probed in this study, apart from a brightening of ~1.3 mag of the characteristic magnitude of the high redshift LF. We confirm, and extend to higher redshift, the result from previous work that the redshift evolution of the characteristic magnitude M* is consistent with passive evolution of a stellar population formed at z>2. The results obtained in this work support and extend previous findings that most of the stars in bright galaxies were formed at high redshift, and that K-bright (M>10^11 Msun) galaxies were already in place at z ~ 1.2, at least in the central regions of X-ray luminous clusters. Together with recent results on the field galaxies stellar mass function, this implies that most of the stellar mass is already assembled in massive galaxies by z ~ 1, both in low and high density environments.