Although the role of motivation has been emphasised in knowledge-sharing literature, traditional motivation theories, such as self-determination theory (SDT), have not been actively used as a research framework in knowledge-sharing research. The purposes of this study are twofold. The first objective is to propose a model, based on SDT, to test the effect of the three basic psychological needs--perceived competence, perceived autonomy and perceived relatedness--on knowledge-sharing behaviours in virtual communities. The second objective is to explore the effects of familiarity and anonymity on the basic psychological needs to better understand individuals' knowledge-sharing behaviours in virtual communities. The results show that perceived competence and perceived relatedness influence knowledge-sharing behaviours in virtual communities; however, perceived autonomy does not influence knowledge-sharing behaviours; familiarity influences positively perceived competence and perceived relatedness, and anonymity influences negatively perceived autonomy and perceived relatedness. (Contains 4 tables and 2 figures.)