Why/How does rabies make people afraid of water?

Hello, I have been researching rabies out of curiosity and there's one symptom I don't really understand how it works biologically. Sorry if it's a dumb question. I have read the FAQ.

How is it people get so afraid of water? I understand that swallowing becomes painful but it seems like even seeing water makes people react in a very scary way. Is it purely a reaction to pain? Is it related to the drooling in any way?