What does 先輩 Senpai mean?

Senpai (先輩) means someone senior to you in the same school or company. It marks a structural relationship, not affection, and carries obligations in both directions.

Written
先輩 (senpai)
Literally
Someone ahead of you in a shared institution. 先 (sen) means before or ahead; 輩 (hai) means fellow or colleague.
As slang
Not slang in Japanese at all. Ordinary, near-compulsory workplace and school vocabulary, used as a title and often in place of a name.
In anime
English-speaking fandom rebuilt it as a word about unrequited attention, largely through the phrase "notice me senpai", which is not a Japanese expression.

A senpai is someone who joined your school, club or company before you did. That is the entire definition. It is a statement about arrival order inside a shared institution, and it says nothing whatsoever about how anyone feels.

The characters

先 (sen) means before, ahead, previous. 輩 (hai) means fellow, companion, a person of one's sort. Together they describe a fellow who got there first. The matching term is 後輩 (kohai), built the same way from 後 (ko, after), and the pair only exists because of each other. You cannot be a senpai in the abstract. You are a senpai to somebody.

The everyday meaning

In Japan this is administrative vocabulary. It is used constantly, in offices and clubs and universities, and it frequently replaces the person's name entirely: you address them as senpai the way an English speaker might say sir or boss, except that it applies to a second-year student talking to a first-year.

The register is neutral and the obligations run both ways. A senpai is expected to teach, to cover for, and to absorb some responsibility for the person below them. A kohai is expected to defer, and to do the tedious jobs. Neither party chose the arrangement and neither is required to enjoy it. You can dislike your senpai intensely and still call them senpai every day, because the word describes the org chart rather than your opinion of it.

What fandom did to it

English-speaking anime fandom collapsed all of that into a single scenario: a younger person with a hopeless crush on an older one who does not notice. The phrase notice me senpai circulated widely enough that many English speakers assume it is a translation of something. It is not. It was assembled in English, on the internet, from a stock anime situation.

The situation is real enough. School romance stories do lean on the senpai relationship, because a built-in hierarchy is useful scaffolding for a story about wanting something you cannot ask for directly. But the word is doing structural work in those stories, not romantic work. The longing is the plot; the senpai is the setting.

Why the confusion is understandable

English has almost nothing here. Senior is corporate and cold. Upperclassman is American, school-only, and nobody says it aloud. Mentor implies a relationship both parties opted into. There is no ordinary English word for a person you owe deference to purely because they arrived first, which is why subtitlers usually leave senpai untranslated and let context carry it.

When a word arrives untranslated, English speakers fill it from whatever context they met it in. For a great many people that context was a romance anime, so the word absorbed the romance. The same thing happened to nakama by way of One Piece. It is the standard fate of loanwords that arrive through fiction rather than through conversation.

Quick answers

What does senpai mean?

Someone ahead of you in a shared institution. 先 (sen) means before or ahead; 輩 (hai) means fellow or colleague.

Is senpai an insult?

Not slang in Japanese at all. Ordinary, near-compulsory workplace and school vocabulary, used as a title and often in place of a name.

What does senpai mean in anime?

English-speaking fandom rebuilt it as a word about unrequited attention, largely through the phrase "notice me senpai", which is not a Japanese expression.