Wireless sensor networks (WSNs) include a number of wireless sensor nodes distributed in a geographical area. Due to the intrinsic and functional nature of WSNs, these networks face many challenges such as limited energy resources of sensor nodes and the routing congestions. Clustering is the most common routing approach to control congestion and achieve energy efficiency in WSNs, which ultimately prolongs the network lifetime. In the cluster-based routing protocols, optimal selection of cluster heads (CHs) is an NP-hard problem, and consequently, heuristic and metaheuristic algorithms can be employed to obtain a near-optimal solution. In this paper, a fuzzy knowledge-based metaheuristic model based on multiobjective fuzzy inference system (moFIS) and bacterial foraging optimization (BFO), named moFIS-BFO, is proposed as an efficient routing protocol for clustered WSNs. In the moFIS-BFO model, the moFIS is utilized to calculate the chance of each node for becoming a CH based on different criteria including degree difference, residual energy, total distance to neighbors, and distance to the base station. Taking into account the calculated chances of nodes, the BFO is employed to select proper CHs at every round. To control the queue in cluster headings, a priority ranking method is used to control congestions and avoid packet wastages. Simulation results demonstrate the superiority of the moFIS-BFO protocol against the existing techniques to control congestion and prolong the network lifetime.