How did photons and electrons arise out of the quark-gluon plasma? I am just beginning to learn about the ideas of the early universe, so this is probably a beginner question.
I understand that protons and neutrons (which are baryons, which are hadrons) are made out of quarks, and quarks are held together by gluons (at a high level). So those are all the ingredients listed in the title "quark-gluon plasma".
But how do electrons and photons come into the picture? Could you describe how this works?
In the wikipedia article Chronology of the Universe, the quark-gluon plasma cools to form hadrons. That makes sense, because hadrons are made out of quarks and gluons.
Then it quickly glosses over a bunch of stuff, basically saying "hadrons and anti-hadrons annihilate to form leptons and anti-leptons, which annihilate... and now the universe is largely dominated by photons interacting frequently with free protons and electrons".
What exactly is happening there? Where did these anti-hadrons come from, and leptons and anti-leptons, and electrons? That's the first time electrons were mentioned.
How did it go from quark-gluon plasma to the formation of atomic nuclei, photons, and electrons? From that point I can imagine the rest and there are lots of resources on how that works, but before that there is very little explanation of the reasoning from what I've seen so far (just wikipedia and arxiv.org mainly).
 A: Gluons and quark-antiquark pairs, like photons and lepton-antilepton pairs, are excitations of the vacuum. Any volume of space with enough energy density to contain a quark-gluon plasma also has, by definition, enough energy density to contain a gas of photons and electron-positron pairs. The difference is that the quark-gluon plasma is governed by the dynamics of the strong interaction, which isn't very well understood, so that's what people are interested in when they talk about it.
Even if you could produce a "purely" hadronic plasma, it would contaminate with leptons and photons as it cooled. The same-charge quark-antiquark pairs in the plasma could annihilate either by producing gluon pairs, thanks to their color charge, or photon pairs, thanks to their electric charge. (Think of the decay $\pi^0\to\gamma\gamma$.) These photons would be available to find each other in the plasma and produce $e^\pm$ pairs.
And electroweak transitions between quark members of isospin doublets would also produce charged and neutral leptons directly (think $\pi^+\to\mu^+\nu_\mu$).
A: The chronology in Wikipedia is emphasizing what is changing in each epoch.  Particles that are lighter than the ambient temperature are presumed to be in thermal equilibrium, but not doing much of interest at that time.  In particular, the light leptons and photons are created and annihilated all the time, so there is a sea of electrons, positrons, and photons around at all times before the temperature drops below 0.5 MeV.  The individual ones come and go, but the bulk of them doesn't change much.  They get emphasized in the lepton epoch as the temperature drops enough for the hadrons to annihilate, but they were there all along.
A: In most quantum processes you cannot get just particles (without antiparticles) as products. That would violate some conservation laws (charge conservation mainly). So the quark-gluon plasma was a mixture of quarks and antiquarks. As a consequence, after the QCD cooled, you get both hadrons and antihadrons. These annihilated, but there was certain assymetry (more hadrons than antihadrons) and thus some hadrons remained after the annihilation.
The leptons (neutrinos, electrons, antielectrons, etc.) and photons were there in the quark-gluon plasma, all the time. They just were not doing anything important at that time, that's why they are not mentioned. More leptons (+antileptons) and photons are created as the QCD cools down (annihilation of hadrins and antihadrons, decay of unstable hadrons). Then the leptons annihilate with antileptons.
A: First clearing up a  misconception. 

I understand that protons and neutrons (which are baryons, which are hadrons) are made out of quarks, and quarks are held together by gluons (at a high level). So those are all the ingredients listed in the title "quark-gluon plasma".

Nope. There are no hadrons in the QGP phase (regarded as a pure phase, I'm discounting the mixed phase - that's mostly a crossover region and isn't a ''phase'', so to speak). In fact, if you look at the QCD Phase Diagram, you can see clearly that the hadrons don't exist at temperatures typical of QGP phase. This fact is also known from lattice QCD simulations, which progressively keep refining the temperature where such a cross-over from hadronic to QGP Phase takes place. (A state-of-the-art example is this one.) So, as pure phases, they are mutually exclusive.
Now, as QGP cools, you go lower down in that graph and get to the hadronic phase - so quarks aren't free anymore, they are confined within hadrons, and these are all you'll find in this ''hadronic regime''. As you probably know, hadrons themselves have decay modes, some of them are the so-called leptonic or semileptonic ones, in which leptons (e.g. electrons) are emitted. Of course, it isn't rare to have photons emitted in hadronic decays too, e.g. see here for examples of radiative decay modes of baryons. 
I think this much answers your question in the title. There can be accompanying sidetracks such as cosmic asymmetry, which aren't included in my answer, but then, they were not explicitly a part of the question either. 
Hope that helps :)  
