Remember that the ferries do not go to tangier itself, but to Tangier-Med, a port 40 km to the east of tangier. Apparently, there is a free shuttle service to Tangier itself, or you can just hitch from the port.
Customs and border crossing patrol will take place on the ferry. You should bring your passport and a pen to fill out the form that you will be given. Sometimes, you have to ask the staff for guidance, since the border personnel expect you to come to them, rather than for them to come to you. You should take care of all passport-stamping before the boat arrives in Tanger because you will have to present your stamped passport page to the authorities before leaving the port.
It took n0id two hours to find a ride in August 2009. Without a basic knowledge of French it would have been much harder. Many trucks already had two drivers, only a few didn't. Truck drivers on the ferry told him that it was much harder to hitch a ride from Tangier to Algeciras, due to the drivers' fear of getting busted for drug-trafficking and the tight security at the port in Tangier. On the other side, security will let you sleep in the gare maritime in Tanger (New Port) if you arrive after 23:00 because there won't be any buses going to Tangier city anymore.
DamnthatTelevision got a ride with the first camion he saw, and crossed the straight with the Moroccan driver, who also bought dinner and let me sleep at his place in Tangier. French was crucial, moroccan hospitality is legendary.
If you are planning on buying a ferry ticket to Morocco, consider sailing out of the little-known port of Motril, which is an hour and a half south of Granada. If you don't want to make the detour all the way to Algeciras, the boat from Motril to Melilla costs about the same as from Algeciras to Ceuta (€36 for adult, €32 for ages 17-21). Drawbacks: Ferries leave only once a day, and the trip is several hours long (although you may enjoy the cruise). Melilla is a bit out of the way, but if you plan on heading straight for Fes or Tazekka National Park, it may be a good starting point.
Coming from Morocco
Arriving by ferry from Morocco you should have tried to locate a ride on or before the ferry. If this failed (as it did in my case) you arrive at the passengers port. Go past the places where there are long distance buses and you'll come to a crossing. Follow the signs to whatever direction you're going to.If your going direction Malaga (many people going long-distance here) follow the signs to Malaga for a couple of minutes and you'll see the huge shipping port. Keep on walking until you come to a roundabout where there will be many trucks going in slow speed and many cars from all over Europe coming from the ferry. Although these cars tend to be full.
If you're going far make sure the driver drives on Playa del Sol or some other motorway and don't avoid them because they aren't free.
Vrana found that if you just walk over to where the cars are being led off the ferry and out of the port area (the roundabout by the main building), you can find a lot of people hitching and cars that stop. She found a ride directly to Amsterdam there.
I found my lift on the same round about but being very lucky. Better, next to the harbour, (you can see also a petrol station but don't ask there) there is alimentary security control for trucks. All trucks trasporting fish or fruit (the bests to go straight in continental europe) must pass by it and stop inside. I arrived there during spanish holiday (semana santa) that's why was pretty hard but normally should be the best. If not straight at the ferry harbour (not the big merchandise one) where cars and trucks go down, there are some trucks that doesn't cross the sea and just wait for containers. Ask them. Fedecicco
Rather than around the harbour is plenty of supposed "cheap hotel" around 10E/night i think. The waiting hall is open 24/24h, is actually safe, controlled and also some other people, locals/homeless/travelers) sleep in it. If you don't find a lift for the ferry or a long lift for Europe, is better sleep there and try the day later instead of move somewhere else. 'Fedecicco'