As demonstrated by this plot, the luminosity of a star is a very strong function of its mass. This "massluminosity relation" is determined by observations of binary star systems used to obtain their masses and measurements of stellar magnitudes combined with distance determinations to find the luminosities of these stars.
Source: University of Oregon Introduction to Astrophysics, MassLuminosity Relation, Image ID: ml.gif
In the early 1900s, Ejnar Hertzsprung and Henry Norris Russell independently made the discovery that the luminosity of a star is related to its surface temperature. Hertzsprung and Russell both used the spectral class (which is related to the temperature) in their plots. They ordered the stars as O, B, A, F, G, K, and M. Since the O stars are the hottest, this means that in the HR diagram, the temperature axis is odd in that the temperature decreases as one moves to the right. When luminosity versus temperature plots are made, stars do not fall randomly on the graph, but instead are confined to specific regions, and evolve as they age through the regions on this graph in particular patterns.
Source: University of Oregon Introduction to Astrophysics, HR Diagram, Image ID: hr.xbm