Water is amphoteric in nature and it behaves both as an acid as well as a base. With acids stronger than itself (eg., H2S) it behaves as a base and with bases stronger than itself (eg. NH3) it acts as an acid.
(i) As a base: H2O(l) +H2S(aq) → H3O + (aq) +HS-(aq)
(ii) As an acid: H2O(l) +NH3(aq) → OH-(aq) + NH4+ (aq)