Will a D in a major elective keep me from getting into a PhD program?
I don't believe any single thing like a particular grade is disqualifying, but it will raise eyebrows in anyone considering you for acceptance. But things happen. If the grade is truly an outlier and you have a good explanation most people will understand. Not all, of course. 

Stress the positives in your background, as you have in this question. Don't ignore the negatives. 

For future reference, however, if it is possible to drop a course late, do so when you are having trouble. Often a Dean's signature may be required for a late-drop, but he/she will be in a position to evaluate your need to do so. I once took too many credits, got into difficulty, and dropped a course to get back to a more reasonable workload. In my case it wasn't difficult, but in the case of illness, especially, most folks at your institution will make an exception to a rule. That doesn't help you now, of course. 

Making an attempt at re-learning, even without a grade, is a positive thing. You can mention that.

Different Universities feel differently about accepting doctoral students straight from undergraduate. It likely also depends on the field, but it is possible in Math, of course. Sometimes a Master's degree is just awarded along the way as a sort of marker. So, while it depends on the University, I don't think that "settling" now for a Master's is a good choice.