JPEG standard lets the compression quality be traded against image quality and viceversa.
DCT computes spatial frequencies for a data set (for JPEG, for an 8 * 8 block).
Except for quantization errors, the spatial frequencies can be converted (using inverse DCT) back into the data set, so DCT is not lossy.
Intuition: spatial frequency (0, 0) is the "DC", "constant", or "offset" for the entire block (how light or dark the entire block is). Higher frequencies correspond to variations in the image: highest frequencies are the sharpest edges.
JPEG uses more bits for the low spatial frequency components. Only the more significant bits of higher spatial frequency components are retained.
The exact algorithm is to divide each spatial frequency (the result of the DCT phase) by a corresponding coefficient stored in a table. The table has small coefficients for low frequencies and large coefficients for high frequencies.
For example, the coefficient for (0,0) might be 4, so only the 2 least significant bits are lost. The coefficient for (7,7) might be 32, so the 5 least significant bits are lost.
JPEG specifies a set of quantization tables.
The variant is that only the length of runs of zero values are encoded -- all other values are encoded as themselves. Since many of the higher-frequency components have been divided by large coefficients, they are likely to be zero.
Also, the DC coefficient is likely to be the same as in the previous block, and is encoded using DPCM.