Don't react right away. Some students may be tempted to start the petition process the very day that they receive their grade. Storming the instructor when you're upset won't make a very good impression and isn't likely to get him to change his mind. Give yourself a few days to calm down so that you can examine the problem rationally.
Check the syllabus to see how your final grade was calculated. Compare the syllabus with the marks you received for different assignments and see what grade you're able to calculate. The discrepancy is most likely to occur in the intangible part of the marking system (participation, attendance). Depending on how much value an instructor places on this section of the syllabus, it's possible to lose an entire letter grade here.
Go to the registrar to obtain the necessary paperwork to petition your grade. Some schools make the forms available online as well.
Fill out the forms as instructed. Most of it is very straightforward. Your student identification number, the course codes and other relevant information should all be included on the form.
Compose your reason for requesting your grade to be changed as succinctly and rationally as possible. State the facts and the reasons why you think your grades deserve a second look without becoming personal and emotional. In cases where the marks you received were largely subjective (the instructor or teaching assistant might not have agreed with your interpretation of a passage that was analyzed for a thesis paper), request that your marks be reexamined.
Submit the forms. Some institutions require that grade petitions be given to the instructor involved while others prefer them to be handed into the registrar's office. Make sure that you have all the necessary forms and attachments. Bundle them together with a paperclip or place them in an envelope to ensure that nothing gets misplaced.
Wait for a response. The course instructor and department chair will look over your petition and make a decision. Whatever they decide is final.