There is a fantastic answer here explaining the connection between geometric and arithmetic genus. In a comment to the answer, the author writes:
I should emphasize that this is not how Riemann and friends knew that $g=\gamma$. Instead, they would have thought in terms of integrating 1-forms (i.e. sections of $\Omega^1$) around loops in X (i.e. elements of $H_1$). But I'll leave it to someone else to explain that story...
How does this story go?
Edit: @Chappers suggests the answer may be in a paper of Riemann's on Abelian functions. Here is an English translation in two parts: Part I, Part II.