I use Gmail as my e-mail client, but when I click on a "mailto:" link, the Mail.app is opened.
Is there a way to avoid the Mail.app opening in this case? Can I open Gmail instead?
I use Gmail as my e-mail client, but when I click on a "mailto:" link, the Mail.app is opened.
Is there a way to avoid the Mail.app opening in this case? Can I open Gmail instead?
Both Google Chrome and Firefox support this functionality. (ok, technically these are third party apps, but lets assume you are not using safari.)

If you made a mistake and selected "No" and you really wanted to select "Use Gmail"
chrome://settings/handlersSource: http://productforums.google.com/forum/#!topic/chrome/hnRteY7bHfE
Alternative way, if you need to do this programmatically.
See @Am1rr3zA answer on this question. Click here to jump to his answer.
See @fpotter's answer on this question. Click here to jump to his answer.
Turns out Google Notifier for Mac is no longer supported.
If you're using Chrome, this is now very simple: open settings, search for "mailto", and set Gmail as the handler for mailto.

For Firefox, see this answer.
(The remainder of this answer is now obsolete.)
While options like Webmailer also do the job, I'll mention yet another way for the sake of completeness:

Besides directing clicks on mailto: links to Gmail, the Google Notifier comes with some additional features: It adds an icon (like this:
) in the menu bar and notifies you (if configured to do so) about new mail in your Gmail box. Through the icon you can also access your inbox, unread messages, and "Compose mail" screen quickly.
Works great for me; I can generally vouch for this useful little app.
If you use Firefox 3.5 or later:

Or you can use More Internet, a System Preferences pane that lets you choose which applications are set as helpers for Internet protocols.

With Webmailer, you can set up any webmail client as the default email client in OS X.

You could use Mailplane. Mailplane is a site-specific browser for GMail that offers better OS-level integration. Mailplane can act as the default email client.
You can do this with Firefox in two steps...