Apparentely NPCs attacking me just because they are on the same side with guards and NPCs will not attack you on they own. So if anyone else faced the same problem, here is a "solution": Kill all guards, do not kill hostile NPCs, go back to ship, sleep for three days, come back to the city: all guards are dead, all NPCs are non-hostile.