Were quarks the consequence of a theory that was later confirmed by experiment (like the positron)? Or were they the first observed empirically and then particle theory had to be adapted to explain their existence?
When I started in high energy physics back in the '60's, there were no quarks. Experiments consisted of scattering electrons , protons, kaons, antiprotons on targets and measuring crossections generally, and searching for resonances among the produced particles in the bubble chambers.
The wiki history is accurate
The Gell-Mann–Nishijima formula, developed by Murray Gell-Mann and Kazuhiko Nishijima, led to the Eightfold way classification, invented by Gell-Mann, with important independent contributions from Yuval Ne'eman, in 1961. The hadrons were organized into SU(3) representation multiplets, octets and decuplets, of roughly the same mass, due to the strong interactions; and smaller mass differences linked to the flavor quantum numbers, invisible to the strong interactions. The Gell-Mann–Okubo mass formula systematized the quantification of these small mass differences among members of a hadronic multiplet, controlled by the explicit symmetry breaking of SU(3).
The spin 3⁄2 Ω− baryon, a member of the ground-state decuplet, was a crucial prediction of that classification. After it was discovered in an experiment at Brookhaven National Laboratory, Gell-Mann received a Nobel prize in physics for his work on the Eightfold Way, in 1969.
Finally, in 1964, Gell-Mann, and, independently, George Zweig, discerned what the Eightfold Way picture encodes. They posited elementary fermionic constituents, unobserved, and possibly unobservable in a free form, underlying and elegantly encoding the Eightfold Way classification, in an economical, tight structure, resulting in further simplicity. Hadronic mass differences were now linked to the different masses of the constituent quarks.
So the sequence was experimental observations, phenomenological classifications, to theory.
It took a while for the SU(3)xSU(2)xU(1) quark model to be accepted generally. There existed the parton model of Feynman competing in the interpretations of deep inelastic experiments, which predicted twojets of particles as the outcome of a scattering. It was the discovery of excess high p_transverse distributions and of three distinct jets that pointed out that the QCD structure was obeyed by the data , so in this sense , theory predicted the behavior and experimental observation followed.
Were quarks discovered theoretically or empirically?
Theory can only propose experiments to be done . Discovery isa matter of data confirming a theoretical proposal.
At present the particle experiments look for beyond the standard model models predictions, new resonances mainly, so the theory is directing the search light of experimental observations.