This paper discusses the finite-time and the fixed-time consensus of nonlinear stochastic multi-agent systems (NSMSs) with randomly occurring uncertainties (ROUs) and randomly occurring nonlinearities (RONs) in a leader-following framework. Nonlinear control and impulsive pinning control protocols are designed to guarantee that follower agents realize consensus with the leader agent in finite time(fixed time). Based on the finite-time and fixed-time consensus theory, stochastic analysis technique, comparison system theory and algebra graph theory, some sufficient conditions are proposed to guarantee the finite-time and fixed-time consensus of systems. Then, the setting times of finite-time consensus and fixedtime consensus are estimated. Finally, two simulation examples are presented to illustrate the correctness of our conclusions. INDEX TERMS Finite-time consensus, fixed-time consensus, stochastic multi-agent systems, impulsive control, ROUs, RONs.