How was funding handled in the medieval university? How was funding of research done in the medieval universities?
Your question is based on a wrong premise: There was no funding specifically for research, because there was no research at medieval universities. Initially, they were created as "self-help" groups of students wishing to learn, first and foremost, the practice of law that was becoming more and more important to urban life. For this purpose, they banded together to pay teachers. (You can find detailed accounts of this in the Wikipedia page or the answers to this question on History.SE). This quickly included also canon law, which brought increasingly many theologians to teach at universities (who, as Stephan Kolassa points out in his comment, did make many significant contributions to the knowledge of the time).

As Darrin Thomas points out, the first research in the modern sense (that cannot be described as doing philosophy) was carried out in the Renaissance by individuals not affiliated with any institution of learning, who were funded either through private means (inheritances, church postings that left them ample free time) or patronage -- in particular, by dedicating self-published monographs to various members of nobility. These later organized themselves outside of the universities in learned societies such as the Royal Society (founded in 1660, but the first seems to be the Sodalitas Litterarum Vistulana, founded in 1488 in Cracow). These initially received no funding (apart from the wealth of their members; for example, Robert Hooke, who built many of the experiments for the Society, became very rich by his involvement in the rebuilding of London after the Great Fire), but later received (modest) grants from the government (hence the name, Royal Society). The role of the universities (as opposed to individual researchers, which might or might not hold posts at one) was seen as that of disseminating the new knowledge.

The idea of universities as a place where research should be done (i.e., professors being hired and paid specifically for their research in addition to teaching, rather than research just being what a good teacher did on their own) is a modern one, arising in the beginning of the 19th century with the foundation of the German universities based on Alexander von Humboldt's ideal (which also strongly influenced the new American universities). To quote:


  Just as primary instruction makes the teacher possible, so he renders
  himself dispensable through schooling at the secondary level. The
  university teacher is thus no longer a teacher and the student is no
  longer a pupil. Instead the student conducts research on his own
  behalf and the professor supervises his research and supports him in
  it.


Much like modern universities, they were funded by the state: A portion of the tax money was distributed among the universities, which distributed their portion among the departments, which distributed their portion among the professors to pay for their salary and any staff or resources they might require for their research. (Needless to say, there was heavy fighting at all levels about how the money was distributed.)

Funding of specific research via grants is an introduction of the 20th century, when technical and scientific innovation increasingly required expensive equipment. Initially, this was done by corporations and private industrialists, but World War II lead to increasing government support of science and technology. This lead to the creation of national funding agencies after the war. (For example, the NSF was founded in 1950, although the German DFG, founded in 1949, actually has their root in the "Notgemeinschaft der Deutschen Wissenschaft" founded in 1920.)