PurposeUsing norms of reciprocity, this study explores how employees' exposure to workplace ostracism (WO) affects their task performance through the mediating role of knowledge hiding (KH). Moreover, drawing on social identity theory, this research outstretches the boundary conditions of KH, i.e. under which KH is less likely to occur.Design/methodology/approachTime-lagged, multisource data collected from 297 employees in service sector organizations in Pakistan were analyzed using SMARTPLS (v 3.3.3).FindingsThe findings reveal that perception of WO provokes KH behavior in employees, which, in turn, deteriorates their task performance. Results also disclose that moral identification (MI) and organizational identification (OI) buffer against the positive association between WO and KH, such that the ostracism-KH link is weaker at higher levels of MI and OI, and vice versa.Practical implicationsThe study envisages that a KH loop occurs between the knowledge hider and the knowledge seeker, which fosters spirals of conflict that might prevail in organizations over an extended period of time. Therefore, the occurrence context of KH should be mitigated through appropriate managerial interventions. In addition, nurturing self-identities will be beneficial for both employees and organizations.Originality/valueThis is the first study that investigates the relationship between WO and task performance while also considering the mediating role of KH and the moderating roles of MI and OI.