As this question came up again, I thought I would add a more simplified version as introduction.
Nuclear physics studies took off when one realized that the nuclei were composed of protons and neutrons. This was organized into the table of elements, periodic table, which counted the number of protons , i.e. positive charges as Z, and total mass as A in atomic mass units. A, almost always larger than Z, gave the count of neutrons, as the masses of protons and neutrons are very close. It was known that it was the number of protons that interacted chemically and diferentated the elements so they were known as: hydrogen ...iron...uranium ... Chemistry depends on electromagnetic interactions.
In addition it was found that for each Z there existed similar in chemistry behavior elements, called isotopes, which had a different A, leading to a different number of neutrons for the same type of element, iron, gold, xxx.
It was known that like charges repel each other . Nuclei with more than one proton will have a repulsion between them. In order to explain the stability of nuclei another force was postulated, a nuclear force that was attractive and worked between protons and neutrons without discriminating between them and treated as nucleons. A balance between the repulsive forces of many protons and the attractive process of many nucleons was postulated to explain the stability of matter. So it is not one force, but a balance between attractive and repulsive forces, and further study showed that quantum numbers also have an important role. The nuclear force is always attractive, the electromagnetic always repulsive in the nucleus. The distance comes in because the closer charged nucleons approach, the largest the repulsion, the strongest the attraction, the balance depends on the strengths and the distance.
Here is the further study simplified:
Before learning about quarks and the fact that there exists three quarks per proton or neutron nuclear forces were modeled descriptively by potentials that fulfilled the observations and gave appropriate energy levels consistent with observations, like the shell model:
1) that the nuclear force was attractive as long as the electromagnetic repulsion from the same charges of protons was low enough, and this balance between the two forces created the elements table
2) at that time protons were considered elementary particles and neutrons were modeled accordingly following an SU(2) symmetry ( isotopic spin)
As fermions, protons and neutrons, they could not occupy the same quantum numbers in the solutions for the potential and that resulted as an effective repulsion, due to the pauli exclusion principle as commented above, not the strong force.
The models quite succesfully explain the periodic table of elements and the radiative and decay behavior of nuclei.
We now know that it is the quarks that are elementary and that the proton and neutron are composed of three quarks each according to the SU(3) strong symmetry, and that the force binding the quarks into the nucleons is very strong and it depends on what is called a "color charge" and a mediating boson, the gluon. Nucleons are color neutral and are attracted to each other with the nuclear force which is a spill over, residual force from the strong colored forces within the proton and neutron.