The French r is one of the sounds that can cause most difficulties for English learners (and indeed learners of other languages that don't have a similar sound). There are actually various possible types of r sound in French, but nowadays by far the most common, standard French r sound is essentially a uvular fricative.
To produce a uvular fricative, the back of the tongue comes very close to the uvula, which is the very end part of the soft palate that "dangles down" at the back of the mouth (see diagram below). The principle is the same as for other fricative sounds like s, z: the tongue comes in close enough contact to cause friction as the air passes between the tongue and uvula (causing the "rough", "irregular" sound that you hear), but not close enough to stop the sound completely.
When practising the French r, for some people it helps to "imagine" that you're pronouncing the sound at the "back of the throat". It's important to note that in reality, this description isn't accurate, though: the friction is in reality produced specifically between the tongue and the uvula1.
In ordinary, rapid French speech, the r is often an approximant between two vowels. This means that the back of the tongue comes close to the uvular, but not quite close enough to cause significant friction, and the r sound therefore takes on a "vowel-like" quality. Listen to the pronunciation of the word arrêt in the examples below.
It is usually voiced before a vowel (i.e. the vocal cords vibrate during the pronunciation of the r), but can often be devoiced at the end of a phrase or before or after a voiceless consonant. So for example, in the pronunciation of the words artiste or train, the vocal cords often do not vibrate through the r sound (or only through a small proportion of it) because of the influence of the voiceless t sound.
rentrer "to come back in"
pupitre "desk", "console"
Listen to these words
Some French speakers also pronounce the r as an approximant or even a vowel when it occurs at the very end of phrase. This appears to be a trend developing among younger speakers, although exact details are not well documented.
1. On the other hand, some languages have a type of sound called a pharyngeal fricative, in which the friction is genuinely made between the root of the tongue and the pharynx.