Mass, or more properly rest mass is simply a property of certain states of "stuff". Basically, if something - an isolated physical system - can be observed to be at rest relative to an inertial frame of reference, then it has rest mass and this Lorentz-invariant property measures the total energy of that system when observed from a relatively-at-rest inertial frame. I'm talking about, of course, the famous, but not general, equation $E = m\,c^2$. If your inertial frame is not at rest relative to that system, then the system's total energy $E$ is given by
$$E^2 = p^2\, c^2 + m^2\, c^4\tag{1}$$
where $p$ is the magnitude of the three-dimensional momentum vector for the system relative to your frame. The rest mass $m$ is unaffected by any Lorentz transformation.
Some systems have $m=0$, and these systems always have momentum relative to your inertial frame. Indeed, you will always observe their relative velocity to be precisely $c$. You can think of rest mass in two ways: it is acquired when system with rest mass of nought is confined in some way: if you put a photon in perfectly reflecting box so that is bounces back and forth, then the box-photon system now has an inertial mass that is $E/c^2$ greater than it was before. That is, if you shove the box initially at rest relative to you, you find that the impulse you need to make it move at a velocity $v\ll c$ relative to you is now $E\,v/c^2$ greater than it was before, where $E$ is the photon's energy. The "mass" constant in Newton's second law has changed a little. Indeed, most (if not all - you'd have to get an answer from a field theorist) rest mass is acquired when a massless system such as a herd of photons, initially always running at $c$ is made to "stay put" in some way. See may answers here, here and method 2 in my answer here for more details.
So you can see that the property of rest mass is acquired by certain interactions and changes of state undergone by massless systems. Most generally, it is a coupling co-efficient that measures mutual tethering together of otherwise massless systems.
Another related way to think of rest mass is as a system's "stay-puttedness". Witness the dispersion relation for a massless particle like a photon: from Maxwell's equations we see that it is, in a vacuum, $\omega = k\,c$: the wavenumber is perfectly linearly dependent on the frequency so any signal or "wave group" we send with a massless field will propagate with a group velocity of precisely $c$: the shape of the wave is perfectly unchanged and we call such waves dispersionless. Since (in 1D) a "bump" $\psi(z)$ propagates in time as $\psi(z\pm c\,t)$ with the same shape, this bump has zero "stay puttedness": it is always moving at speed $c$. Contrast this with the dispersion relationship for one electron which you can derive from the Klein-Gordon equation (which all particles fulfilling the Dirac equation must fulfill, although the converse is not true): we get
$$\omega^2 = k^2 c^2 + \frac{m^2\,c^4}{\hbar^2}\tag{2}$$
which you can also derive from (1) with the de Broglie relationship $p = \hbar k$ and Planck relationship $E = \hbar\,\omega$. If we make $m$ bigger and bigger, we can get a group velocity $\mathrm{d}_k\,\omega$ as small as we please. The particle will still be subject to the Heisenberg uncertainty principle, but you can play around with wave-packets and show that the bigger the $m$, the more we can make even a small wavepacket (small $\delta\,x$, therefore big $\delta\,p$, by the HUP) behave like a classical, motionless point object. $m$ measures how readily a quantum system can be made to stay put.