What I am about to describe is what will get you through some of the most obnoxious border crossings in the world. Most border crossings will not be this bad. So don't let the rest of this entry scare you.
There are two kinds of obstacles you will face when going from one country into another: official hassle, and unofficial hassle. Official hassle can include legal entry requirements, border guards, health inspections, and customs. Unofficial hassle can include transport to and from the border, transport across the border, money changers, and other assorted (un)helpful characters looking to either run a genuine business with international travelers, or simply make a fast buck off of people who don't know the frontier.
For both kinds, the best way to avoid it all is to do your homework and find out where the best border crossing for you lies. Occasionally you can save yourself money and stress (plus get prettier views) just by asking around and reading your guidebook. After you've got a favorite crossing, get the specifics on it. If possible, you want to know the hours of operation, each of the administrative fees you need to pay, and the approximate price of transport to, across, and from the border. If there is a particularly notorious scam for this crossing (for example fake officials claiming to sell "required medical insurance" to uninsured travelers from China to Mongolia), you'll want to know that in advance as well, and how to avoid it. Finally check how easy or hard it will be to change your cash from one country's currency to the other once you get across the border. If it looks really hard, consider changing to Dollars, Pounds, or Euros before crossing, or just spending it on food or other supplies before you leave (leaving enough for fees and transport costs). I know this sounds like a lot written down, but once you're actually looking it all up, it won't take that long.
Once you've chosen your border crossing, double check entry and exit requirements online and make sure you have everything else you need to get across the border according to your state department/foreign ministry (more on this in an upcoming post on visas).
After you're armed with information and (if you need it) paperwork, catch your bus, train, boat, plane, or whatever it is that's going to get you to the crossing.
We'll start with unofficial hassle. This is more of concern in poorer countries with less infrastructure and more lax law enforcement.
First is getting there. Get public transport. If the cost isn't posted, watch how much a local pays, or ask two other passengers on board, then pay that amount, making sure you get your change. Know whether your transport gets you to the border, or across it and into a new town (more expensive, but often faster and much more convenient).
Second is money. You will likely get offers to change cash on the street. Do not do this under any circumstances unless you have absolutely no way of avoiding it. I don't care how "official" they are or what badges they flash at you. Some of these people are honest. But many will either try to pull a fast one on you with the exchange rate, and/or hand you counterfeit bills. Just because you've caught them doing one of these things doesn't mean they're not doing the other as well. Find someone who has a rate written up on a sign and is seated in an office or something similar that can't just disappear in the next 30 minutes if you find out you've been ripped off.
Next is getting to the exit station, where you'll get your passport stamped with (surprise) an exit stamp. Know the fees-- if any official tries to ask for a higher fee, gently correct them, and/or ask for a receipt. This is usually enough to set them straight. We'll cover more of this in "official hassle." Double check to make sure your passport has actually been stamped
At this point you'll find some space of no man's land. Sometimes this can be crossed on foot. If you've paid for transport to the next town, you can usually just get back onto the bus at this point. If you can't do it on foot, try to share transport and push past the oh-so-friendly taxi drivers and touts offering, in English, a private ride (unless they're really the only deal in town). Ignore similar friendly strangers offering to help you across the border, as they almost always ask for a fee for guiding you down ten feet of obvious well-trodden paths and make trouble if you don't pay them.
Next is the entry station for the new country. Same process as with the exit one. Once again, double-check that your passport has been stamped, and this time make sure the date is accurate. This is important. If it's not obvious how long you're allowed to stay in the country for, ask.
Finally there's getting away from the border. If you paid for transport all the way, just get back on board. Otherwise, ignore the touts, and follow the locals to the bus stop, train station, or whatever the way onwards is (which you'll know already from having done your homework).
Now that we've covered all that, let's work on official hassle. There isn't much of this in the developing world, but you'll find a lot more of it in modern, developed nations.
The most major source of official hassle is getting a visa. This won't actually come up that often, but when it does, it takes work. I'll tell you more in my next tip post. For now, we'll concentrate on the actual border crossing.
This starts with the exit station. Here you will be handed a departure form of some kind, and possibly a customs form. These are usually very easy: name, date, sex, passport number, expiration date, occupation, and signature is usually all you need. Exit fees are rare as long as you haven't overstayed your visa or entrance limits. Once you have your exit stamp, move on.
The next part if the entrance immigration post. You will usually be given three forms: an entrance form (this will be a visa form if you're supposed to get one at the border), a customs form, and a health questionnaire. Answer everything on the entrance form as honestly as possible. It will be similar to the exit form, but with a few extra questions about your length of stay (exaggerate to at least 30 days unless you now you aren't legally allowed to), purpose of travel (unless you'll be working a paid job, always put tourism-- I've heard of "volunteers" being thrown back onto planes in some African countries) and your contact info and address in the country ("backpacker hostel" and then the city name is usually enough, but the name, address, and phone number out of a randomly chosen hotel in your guidebook is just about guaranteed to work). Aside from the length and contact, fill in everything as truthfully as you can. If you don't know the answer to a question, leave it blank. If they really need an answer, they'll ask for it.
Next is the customs form. If you're a backpacker, the most you'll usually have to declare is the cash you're carrying, and often you won't even need to do that. Just read the form carefully and answer according to your own judgment. If in doubt, honesty is the best policy. Just because you declare something doesn't mean you'll be charged anything for it, but if you're caught not declaring something you should declare, you can be fined, lose the item, or even arrested in extreme cases.
Finally there's the heath questionnaire. Hypochondriacs beware, this is not the time to report the itchiness of your throat or slight upset stomach you just started feeling a couple minutes ago. You will be asked if you have experienced a list of certain symptoms within the last few days like fever, dizziness, diarrhea, etc. Unless you have had one of these things to such an extent that you have seriously considered visiting a doctor about it, do not check yes next to any of them. These forms are not trying to weed out those with indigestion or the common cold, they're trying to weed out H1N1 flu, the West Nile virus, and other serious pandemics. If you answer yes to these questions, you will still likely be allowed into the country, but not after a long round of poking and prodding, not only for you, but possibly everyone else who is sharing your vehicle into the country as well.
After your paperwork is in, you will be handed your passport. I know I mentioned it already but this next step is the crucial one that many people mess up, so I'm saying it again: open your passport and check your new entry stamp, and how long you are allowed into the country. If it's not clear from the stamp, this is your best (and often only) opportunity to ask.
And that's it! Usually anyway. Often there will be a little extra you'll have to deal with, but these guys are pros and if they don't tell you what you're supposed to do, someone else in line with you will. After that, congratulate yourself on entering another country, get out there and have fun!