How important are the grades compared to the cover letter when applying for a Ph.D? Some months ago I finished my MSc. I immediately started to send several applications for Ph.D vacancies.
So far I've spent a lot of time in doing this, but there is only one place that did not reject me. This place was actually the least interesting for me in terms of the job, therefore I was not keen from it at all.
I believe almost no one applied for the place I was not rejected by...
As for all other applications, I'm seriously thinking the problem is my final MSc mark.
To tell the truth with my mark I can access to most of the Ph.D programs (it's a UK "merit"). 
However if I know there are almost no chances for me to do what I would like to do then I resort to something else and avoid waisting my time in writing cover letters that no one bothers.
When I look at an application there are four aspects that count:


grades
cover letter
earlier written work (BS/MS thesis)
Recommendation letters


Out of these, I focus most of my attention on the latter two: if the thesis is well-written, has received a good grade, and the letters of recommendation support the candidate in terms of ability to do research (from reading up on the field to writing everything up) and independence (how much (or little) support the candidate needed.

The cover letter would not make the application, but could break it if it is unfocussed and does not show any skills in expressing the interest in a structured way while avoiding irrelevant information. The grades would, in most cases, be the least interesting since they primarily show one's ability to read and understand, not necessarily reasoning and deduction. The exception is the grade for the thesis.

So, to answer the question, I am not sure which might be more important but anything that supports your ability to do research is of prime interest to anyone evaluating an application. 

EDIT: To follow up on Gerrit's suggestion, my personal ranking list would be (in falling order):


Earlier written work
Recommendation letters
Cover letter
Grades (although the grade on the written work is included in 1)


But, all parts are useful and in the end some mix of all will be used. I would also add that 1 and 2 will "make" the application while 3 and 4 will mainly help to "break" the application.