Answer:
The friendship between Harry and Hermione did not come into existence immediately in the same way that Harry and Ron's friendship began moments after they first met. Their first encounter was on the Hogwarts Express (to the castle) in their first year. Harry and Ron thought she was pretentious and at best Hermione considered the two of them affable (at worst she thought they were idiots).
Either Hermione valued Ron's opinion or had really low self-esteem in her first months (which is magically overcome by year's end), because she cried her eyes out after he made some disparaging remarks about her and she overheard. This led to the confrontation with the Troll in the Girl's Bathroom, wherein she did the first openly friendly thing: lying to a professor to prevent Harry and Ron from getting in trouble for trying to save her.
They start to become genuine friends by the time of the Quidditch match by which point Harry is on his quest to prove Snape's maleficence. Hermione joins somewhat begrudgingly and this quest really cements their friendship as it uses Hermione's intuition and Harry's incessant need for more information/control.