From Wikipedia:
Sensei (先生) is a generic Japanese term for "master", "teacher" or "doctor". It can be used to refer to any authority figure, such as schoolteacher, professor, priest, lawyer, or politician. It can be used on both genders.
Sensei is most commonly used in a school, by both students and teachers and is considered a more friendly term than calling him or her by the family name plus sensei. A male teacher Ichiro Tanaka would initially be called "Tanaka Sensei" by his students and after a while, students switch to "Sensei" or "Ichiro Sensei" depending on how Tanaka sensei would like to be called. Fellow teachers may call each other sensei after getting familiar, but when they consider each other friends, they usually start calling each other by the family name alone, the first name, or by a nickname. Females are more likely to call each other by the first name after becoming friends.