B. Riemann, Theorie der Abel'schen Functionen, Journal für die reine und angewandte Mathematik 54, 101–155 (1857).
Here is a description of this contribution, by Jeremy Gray:
In this 1857 paper Riemann established the existence of complex functions on a surface with no boundary. He supposed the surface was p-fold connected which means that it is rendered simply connected by p cuts when it forms a p-sided polygon. He showed that there are p linearly independent everywhere holomorphic functions defined inside the polygon by considering what would happen if the real parts of their periods all vanished (using the Dirichlet principle). Later he showed that the differentials of these functions are everywhere defined holomorphic integrands. Then he specified d points at which the function may have simple poles, again imposing the condition that the functions jump by a constant along the cuts. Now he argued that to create functions with only simple poles and constant jumps one took a sum of p linearly independent functions with no poles plus functions of the form $1/z$ at one of the specified points and added a constant term The resulting expression depends linearly on $p + d+1$ constants. The jumps therefore depend linearly on $p + d+1$ constants and there are $p$ of them to be made to vanish (if the function is single valued as required). So there will be non-constant meromorphic functions when $p + d+1-2p\geq 2$, i.e. $d>p$. This result, today called the Riemann inequality, says there is a linear space of complex functions of dimension $h^0>d+1-p$ and this contains non constant functions as soon as $d+1-p>1$ or $d>p$.