Unlike other countries, trains here get fully-booked months in advance. It is always better to plan and book ahead. I want to share the steps on how I was able to book our intercity train tickets in India. It's not very easy so you have to be patient.
1) Register or create an account with Cleartrip. An awesome booking website which is very simple and easy to use. When you're done with this, go to the next step.
2) You also have to sign-up with IRCTC (Indian Railway Catering and Tourism Corporation). Fill out all required information (marked with red asterisk). Put in your real name as it shows on your passport as they will need it for verification purposes later. For the mobile number, just put in your real mobile number from your country. It wouldn't matter anyway.
When your done with this, you will receive an email from them containing your temporary password and a link to activate your IRCTC account. However, in order for you to do this you will also need a mobile verification code which was sent to your "mobile number". Obviously, you can't receive it since it's a non-Indian mobile number.
3) Here's what you can do. Send an email to their Customer Care at firstname.lastname@example.org requesting for your mobile verification code. Tell them that you don't have an Indian mobile number and give them your UserID. Attached a scanned copy or your passport (first page, the one with your info) so they can verify your identity. They will then send it to you so you can continue with activating your IRCTC account.
4) You can't book your train tickets directly in IRCTC if you don't have an Indian credit card. This is the reason why we created our Cleartrip account at the first place. Now, you have to link these two accounts so you can book tickets using your non-Indian credit card.
When you log in to your Cleartrip account and proceed to Search Trains and Check Availability, there will be an option for you to Link your Account to IRCTC, click that. You will receive an email with your Email OTP but then again the Mobile OTP was sent to your "mobile number" which of course you can't retrieve.
For this process, you have to email email@example.com again requesting for your Mobile OTP this time. Tell them your User ID and let them know you want to link your account to Cleartrip so you can book using your non-Indian credit card.
Once you receive it, you can go ahead and enter your Email and Mobile OTPs to the Cleartrip website. That's it! You can start booking your train tickets using your non-Indian credit card! :)
Please note that when you log in again to Cleartrip to enter your OTPs, just click the link at the left side, which is something like "Already received your OTPs". Do NOT try to link your account again because it will send you another set of OTPs and you would have to redo the process again!
It was quite a long procedure but I'd like to commend the IRCTC Customer Care for their prompt responses. You can finish this in 2-3 days. Not bad at all.
Latest Update 12/14/14
If booking ahead is not your thing or simply everything has been sold out, here are the other options left:
Foreign Tourist Quota (FTQ)
They do allot a few seats for foreign tourists who want to travel on a short notice. Tickets might be available a couple of days or a day before your desired travel date. But still, there's just a little assurance that you can get one especially if you're coming to or from a very popular tourist destination or if it's high season. Not all stations have this quota. Here are the stations in Northern Railways that have FTQ: Kolkata, Chennai, Bangalore, Ahmedabad, Jaipur, Jodhpur, Varanasi, New Delhi, Agra-Cantt and Mumbai.
We were able to avail FTQ tickets in Varanasi. We availed Varanasi Junction-Agra Fort tickets for the same day. Only one seat in AC2 was available so one of us had to be on the Waiting List (WL). Everything else was fully-booked so we took it! We were advised to return at least an hour before our departure that night to confirm the WL ticket. To book this, just look for the Tourist Assistance Office in the train station. Ticket prices were the same, no additional charges.
This refers to the tickets being made available only at 10:00 AM a day before the travel date. The difference it has from the FTQ is it has an additional charge on top of the ticket price. It ranges from INR 15-400 depending on the seat class. This can also be booked online.
We were also able to try this option when we had to reschedule our Agra-Jaipur trip. We booked this online via Cleartrip. Additional TATKAL charge is very minimal so we did this instead of going to the train station just to book it.
I hope this helps you out in planning your trip to India. Feel free to comment if this post has helped you or if you want to correct or add something. Happy travels! :)