This is a slightly derogative term for foreigners (generally Westerners). A good equivalent would be gringo, a foreigner who is kinda outta place but in a somewhat funny sort of way. Many Japanese who I know insist this is a term of endearment, but when everyone refers to you as "Hey gaijin!" or "hey look at the gaijin" you feel a bit like an animal in a zoo. A lot of this stems from the fact that in Japenese pop culture America is seen as a very alien world, so when Japanese people see gaijins they are somewhat of a curious oddity.