"Gaijin" means "outside person", i.e. foreigner. I'd say it has a deeper meaning that "foreigner" though because 99% of the population in Japan is Japanese compared to western countries where there are millions.
Gaijin get treated pretty normally in Japan, a few stares though but generally people leave you alone. I found that Chinese and Korean gaijin have a worse reputation that westerners though, but it's not like they get lynched or anything, just blamed for stuff like crime increasing.
Some Japanese people will only want to be friends with you just so they can practice their English, however many do not have that agenda.
There are a few places that won't accept you because you're a foreigner. A couple of times we went to go to pubs in Tokyo and got told "no, no, Japanese only", but 95% of places will happily accept you. The reason why some places might be hostile is usually because of language and cultural issues.