In a nutshell
“mixing” is adjusting the levels (and things like compression, EQ, effects, etc.) of individual tracks against each other.
“mastering” is taking the final mix and adjusting the whole track’s EQ, compression, etc. to create a final product.
Often mastering has a particular target which, historically, could be for vinyl, cassette tape, CD, radio-play, etc. as different media have different requirements. For example, mastering for vinyl is important because vinyl has some significant physical limitations, such as too much low-end causing the needle to skip on playback. If you are interested, here’s a good guide:
For modern music distribution, mastering targets are using things like Spotify, Youtube, Apple Music, etc. as some of these have different requirements. Ardour actually has a bunch of pre-canned settings to accommodate different “loudness” profiles for different media, as well as different physical format.

“Loudness” is an important part of modern mastering, but it’s not the whole story, mastering covers a whole lot more. You may, for example, want to also change the EQ to suit certain listening scenarios (e.g. someone listening on a car stereo whilst driving) or you may want to make other “artistic” changes, such as boosting the overall level of the final chorus slightly.
That’s really a high-level overview. Mastering is a complex subject and there are whole books written on the subject.
But hopefully that’s enough to understand the primary difference between “mixing” and “mastering”.
Cheers,
Keith