Network congestion is one of the major issues in wireless sensor networks (WSNs) that result in packet loss, reduced network lifetime, low throughput and energy waste. Determining a better path to mitigate the congestion is a better approach to improve the performance of WSNs. In this paper, an adaptive neuro-fuzzy inference system (ANFIS) based path determination approach is proposed to mitigate the congestion with black widow optimization (BWO) algorithm. The hop count, buffer occupancy and remaining energy are considered as the input factors for the ANFIS. The simulation results of the proposed method show better quality of service, high energy, low delay, high packet delivery ratio with number of increasing alive nodes when compared to existing methods.