Their relationship develops subtly throughout the books. They share a common bond in being outsiders and facing prejudice, and they come to appreciate each other's unique qualities.
Their relationship is confirmed in the final book, *Harry Potter and the Deathly Hallows*, where they are seen together at the Battle of Hogwarts.