How can a pirate ship sail against wind?
Some types or rigs are better at this than others. Generally speaking sail propelled vessels are constructed for the type of conditions they expect to encounter. For example a Cat boat is rigged in such a fashion to sail tight to the wind, they were made to move around in congested harbors. Boats like Hudson river sloops were designed to sail downwind efficiently, because you have to sail either up or down the river.