The atomic number originally meant the number of an element's place in the Periodic table. When Mendeleev arranged the known chemical elements grouped by their similarities in chemistry, it was noticeable that placing them in strict order of atomic mass resulted in some mismatches. Iodine and Tellurium, if listed by atomic mass, appeared to be in the wrong order, and would fit better if their places in the table were swapped. Placing them in the order which fit chemical properties most closely, their number in the table was their atomic number. This number appeared to be approximately proportional to the mass of the atom, but, as the mass/chemistry discrepancy showed, reflected some other property than mass.
With the discovery of atomic structure, this anomaly was resolved; the mass being the sum of the protons and neutrons in the atomic nucleus, while the chemical properties derive from the number of electrons in the atom, which matched the number of protons.
See: Periodic table