How did ships in the age of sail get into port?

by polishprocessors

I've recently seen a few old engravings/drawings of ships from Roman to Medieval times in very small ports/harbors. How did these ships, particularly larger merchant ships which had to load/offload cargo, which I thought were only powered by their sails, put into port, particularly complex ones with defensive structures to avoid? Were there tugboats powered by oarsmen, or was it just a slow process of tacking with the wind or something else entirely?

Moskau50

Here's a previous version of this question, with some information provided by /u/mormengil.

Edit: Credit.