Let's say I want to land in Minsk, stay there for a few days, and then leave by train to Vilnius.
Where will my migration card be checked upon emigration?
Two trains go from Minsk daily. The first one departs from the Belarusian capital at 7:45 a.m. and returns at 18:10. The second train from Minsk to Vilnius leaves at 18-50, and comes back at 6:05.
What happens, in most border crossings by train is that there's a stop on either side of the border, often at an 'empty' station. Border guards get on the train, and check your paperwork, as well as issuing you with any other paperwork you may need for entry into Lithuania.
Then you carry on to the other side of the border, where a similar process repeats itself.
I would suspect that it's done in Godagai, 10km pre-border, but don't worry - they'll explain it, or just make it happen. Neither country is going to let a train-load of passengers cross the border without checking/issuing paperwork!
Sometimes, as in the case when travelling between Poland and the Ukraine, the rail guage is different, so they do the passport stuff while lifting the train and changing the wheels. It's a very interesting experience.
I haven't done that border crossing, but I've been between Poland and Lithuania, and detailed my experience on my blog, if that's of any assistance.
Your Russian/Belarusian migration card should always be in your passport booklet. Once you approach the border, there will be a stop somewhere close by. I don’t know where the stop is on your route, but on the typical Warsaw–Minsk route from Poland, Poland performs their border controls in Terespol and Belarus in what looks like barracks with a platform somewhere between the border and Brest proper. It will be similar. (Note that the break-of-gauge operations were not performed until after the train stopped in Brest for people to get off.)
Upon stopping at wherever the checks are performed, border and customs officers will board the train and go from compartment to compartment. They will ask for your passport, open it, grab the migration card and stick it to a pile they are already carrying. They will exit stamp your passport and hand it back. If they have a really, really, really good day, they might say something like ‘thanks’ or ‘have a nice trip’ (in Russian or Belarusian, of course; as if they spoke other languages!), but that practically requires snow in July. Customs will ask you a few questions about what you are taking out of the country.
Then, after all passengers have been checked and stamped, the train will move on slowly through no-man’s land until it reaches Lithuania. The same procedure but from the other side and without a migration card. There is no break of gauge as both countries use Russian broad gauge and so your train will then happily continue to Vilnius.
Just because the last stop is ten kilometres from the border and the next one is in Vilnius does not mean that those are the exit/entry points. It depends on the exact infrastructure present.