Ahoy mate! This common pirate phrase may mean more than you realize!
Pirates are known for eye patches, walking the plank, and collecting booty, but there are more pirate traditions than you might be aware of, like the fact that same-sex relationships were quite common among the pirates of the Caribbean. Matelotage was a gay marriage of sorts practiced by male pirates from the 17th century. Some of the most successful pirates had relationships with other men as a means of companionship and protection. Having a mate was both a personal and professional arrangement for a pirate - and the word 'mate' itself is probably a holdover from the institution of matelotage.
During the 1600s, pirates began to enter into civil relationships with one another, known as matelotage. Matelotage, meaning "seamanship," derives its name from the French word for sailor or seaman, matelot. Aspects of matelotage were practiced by sailors and pirates alike but the latter did it openly. Pirates that entered into the bonds of matelotage shared everything - affection, possessions, and even other sexual partners.
From ancient Greece to the Roman military to medieval Japn to modern prison culture, the bonds of men have resulted in same-sex relationships that can be considered romantic and erotic as well as formative and practical. Spartan boys were trained from a young age by other Spartan men, Roman soldiers were allowed to have same-sex relationships with slaves or prostitutes, samurai practiced wakashudo (translated as "the way of the youth" and very similar to the Greek tradition of men training boys), and "situational homosexuality" exists in all-male prisons. Matelotage, as an institution that developed on ships full of men, is another one of these "homosocial" bonds.
Same-sex relationships on the high seas were not unique to the 17th and 18th centuries either. There are accounts of the Heruli, an ancient Germanic tribe, practicing homosexuality in their warrior-based culture as mercenaries and pirates alike.
Much of Europe was ideologically against same-sex relationships during the 17th and 18th centuries, describing them with terms like "sodomy" and "buggery." Homosexuality could be punished by death, although it rarely was. With pirates defying social norms in pretty much every way, their acceptance of such taboo relationships arguably fits into their general way of life. Sailors, on the other hand, were deterred from such practices. The British navy actively tried to prevent same-sex relationships on ships in the 17th and 18th centuries but with ships full of men, sailors tended to become intimate. The same is true for pirates.
Ironically, homosexual relationships in European society were associated with (and often tolerated, as a result) the wealthy and elite, who were considered to be above the law. It soon became a known practice among pirate outcasts, outside of the law, who supposedly used "bugger" as a term of endearment during the 18th century.
For pirates, the relationship of matelotage was a much more public and accepted practice. Naval sailors would have to take such relationships under-ship, so to speak, but pirates readily approved of formally entering into a committed relationship to another man. As it came into greater usage, 17th and 18th century buccaneers in the Caribbean specifically used the word matelot to refer to their sexual partners. The relationship between buccaneer and matelot was affectionate and intimate as well as social and economic.
French and English seafarers both used the term matelot but when the English incorporated it into their parlance, it meant "buddy." It was later shorted to just "mate" and continues to be used in the buddy-context today.