My understanding is that they both refer to "beans." But there are several types of beans. For instance, there are round, "starchy" kidney type beans. And there are long, stringy "green" beans. Could "frijoles" refer to one type of beans and "habichuelas" the other type? How do you tell the difference between them, and maybe "third" types of beans?
Given the great extension of territories where Spanish is spoken, there are for a single type of food, many ways to name it, according to the country (or region in a single one).
There's also an opposite case: the same word refers, in two regions, to different varieties of the same food, or even to two different ones.
For your specific question:
This is how in México is called many varietis of Phaseolus vulgaris:
But, as I've already said, this food is called with these different ways:
According to what I've found, in most places habichuela is called the same Phaseoulus vulgaris, but when served green, inside its pod.
"Frijol" is not a common word in Spain, where we use mostly "judía" (also "haba" or "alubia" depending on zones).
In this context, "habichuela" is the long, green pod (containing small beans) depicted at http://upload.wikimedia.org/wikipedia/commons/f/f6/Habas_frescas.jpg while "judía" (and its american synonym "frijol") is the single bean depicted at http://upload.wikimedia.org/wikipedia/commons/3/33/Bruine_boon_Noordhollandse_Bruine_(Phaseolus_vulgaris).jpg
There is a wide variety of both pods and beans, in size, shape and colour.
judías o habichuelas se usa en España
frijoles se usa en América
las judías verdes o habichuelas verdes son las vainas tiernas comestibles de la planta. En partes de Centroamérica, por el náhuatl ¨exotl¨, le decimos ejote.
En partes de América pronuncian frijol, con el acento en la i, no sé por qué razón.