A carajillo is espresso with a spirit in it. In Spain that usually means brandy, rum or anís, served in a small glass, with or without sugar.
The story
The name is usually traced to Cuba under Spanish rule, where soldiers were said to have added rum to their coffee for corajillo — a little courage — before duty. Like most etymologies of this kind it is probably tidier than the truth, and it has stuck.
The Spanish version
Espresso, 20 to 30 ml of spirit, optionally sugar. Some bars flame the spirit with sugar and a lemon peel first, which burns off some alcohol and caramelises the sugar; others simply pour.
It is a working drink and an after-meal drink, and it is unpretentious.
The Mexican version
Entirely different, and now the more famous of the two. Licor 43 — a Spanish vanilla liqueur — shaken with espresso and poured over a large ice cube. Sweet, cold, vanilla-heavy, and closer to an espresso martini than to the Spanish original.
If you order a carajillo in Mexico City and in Madrid you will receive two unrelated drinks. Both are correct in their own place.
Making one at home
The Spanish way: pull an espresso into a small glass, add brandy to taste, stir, add sugar if you want it.
The Mexican way: 50 ml Licor 43 and a double espresso, shaken hard with ice, strained over a fresh large cube.
Relatives
Italy’s caffè corretto is the same idea with grappa or sambuca. Ireland’s coffee is a longer, creamier cousin.