Whereas phonetics is about the nature of sounds (or phones) per se, phonology describes the way sounds function within a given language. For example, /p/ and /b/ in English: due to mimimal pairs such as "pin" and "bin", it is clear that /p/ and /b/ are distinctive units of sound in English, i.e. phonemes.
Different phonemes can be spelled the same way ("good" and "food" have different vowel sounds), so one should use the International Phonetic Alphabet (IPA) to denote phonemes. Much of the phonological study of a language involves looking at data (phonetic transcriptions of the speech of native speakers) and trying to deduce what the underlying phonemes are and what the sound inventory of the language is.
A minimal pair is a pair of words, both of which are in a language, which are recognized by speakers as being two separate words, but which only differ by one phoneme, as far as the language is concerned. Even though a language may make distinctions between a small number of phonemes, speakers actually produce many more phonetic sounds. Thus, the definition of a phoneme in a particular language is a set of phonetic sounds that all associated with the same phonemic sound in the brain. A Chomskyian linguist would say they are translated to that same sound, while a Lambian stratificationalist would say that the phonetic sounds were on a separate level in the brain. Likewise, the production of these different sounds is completely determined by language. When there is a minimal pair, then those two sounds constitute separate phonemes, otherwise they are called [[allophone]s of the same underlying phoneme. For instance, voiceless stops (p,t,k) can be aspirated. In English, word initial voiceless stops are aspirated, whereas non word-initial voiceless stops aren't aspirated (This can be seen by putting your fingers right in front of your lips and notice the difference in breathiness as you say 'pin' and 'spin'). There is no english word 'pin' that starts with an unaspirated p, therefore in English, aspirated [p^h] (the ^h means aspirated) and unaspirated [p] are allomorphs of an underlying phoneme /p/. This is not true of all languages however - both cantonese and thai make the distinction between [p] and [p^h], so in those languages, /p/ and /p^h/ are separate phonemes.
Another example... in English, the glides, /l/ and /r/ are two separate phonemes (minimal pair 'lead', 'read'), however in many asian languages the two glides are allomorphs, and the general rule is that [r] comes before a vowel, and [l] doesn't (e.g. Seoul, Korea). If you ask someone who is a native speaker of korean, they will tell you that the [l] in Seoul and the [r] in Korea are in fact the same letter. What happens is that a native korean speaker's brain uses the underlying phoneme /l/, and depending on the phonetic context (before a vowel or not) this phoneme gets expressed as either the [r] sound or the [l] sound. Another korean speaker will hear both sounds as the underlying phoneme and think of them as the same sound. This is how different languages can have varying numbers of sounds in their inventory, even though there are a constant number of distinct phonetic sounds that humans can make.
The particular sounds that a language decides to make distinctions between can change over time as new children learn the language. At one point, [f] and [p] were allophones in English, and these changed later into separate phonemes. This is one of the main factors of historical change of languages as described in historical linguistics (another being fast change resulting from influence by another language, e.g. French influence on English after 1066).
Stress and tone are also part of phonology. In some languages, stress is non-phonological, e.g. in Finnish or in Germanic languages (to check. In contrast, most modern-day Germanic languages such as German or English, stress is indeed phonologically distinctive, although there are only few minimal pairs, e.g. /'august/ 'August (the name)' versus /au'gust/ 'August (the month)' in German, or /con'verse/ 'converse (to hold a conversation)' and /'converse/ 'converse (the opposite of something)' in English.