I second (or third) what the others have said about proper form. It's harder to do than you think; I see a lot of improper form on squats and lunges in the classes I take at the gym. See if you can get the instructor to help you before or after the class.
Stretching is also really important. My experience at Bally's is that the instructors don't always have the class do a really good stretch at the end. I usually end up stretching on my own after class.
You might want to try knee braces (the ones you can get at the drugstore with the hole over your knee cap), especially if the pain is under your knee cap and it particularly hurts to go down stairs. That can be caused by the knee cap sliding to the side when you bend your knee--it's the exact problem I have and the knee brace has definitely helped.
You also might want to try some exercises to strengthen your supporting leg muscles. Here are some
exercises my doctor recommended that I do. These also include a couple of good stretches.
Another thing to try is icing your knees. You can do this in the evening while you are watching TV. Ice it for 15-20 min, then take the ice of for 40-45 min, then ice again for 15-20 min, etc. etc. Also, Ibuprofen can really help.
Another thing my sports medicine doctor recommended is massaging my knee. He told my to sit with my leg straight, to push my knee cap down towards my foot slightly (not a lot) and then lightly massage under the knee cap. I do it for 20 min or so every night when I watch TV. It is increases blood flow to the knee, which helps expand the blood vessels and generally improves circulation. When I first started doing it, my knee was pretty sensitive but it has definitely improved as I've continued to do it.
Finally, I've been rubbing
Blue-Emu Oil on my knee and it has been a true miracle. I rub a nickle-sized dab on my knees twice a day and it's been the difference between not being able to run at all and being able to run intervals. My stepmom has arthritis in her knees and recommended it to me. I was very skeptical at first, but desperate, and it really has made a difference. It has glucosamine in it, which is supposed to help with joint pain.