The wireless sensor network is an intelligent self-organizing network which consists of many sensor nodes deployed in the monitoring area. The greatest challenge of designing a wireless sensor network is to balance the energy consumption and prolong the lifetime of the network, seeing that the nodes can be powered only by batteries in most conditions. An energybalanced routing protocol (EBRP) for wireless sensor networks is proposed in this paper. In EBRP, we divide the network into several clusters by using K-means++ algorithm and select the cluster head by using the fuzzy logical system (FLS). Since the previous researches did not demonstrate how to get the fuzzy rules for different networks, we propose a genetic algorithm (GA) to obtain the fuzzy rules. We code the rules as a chromosome, and the lifetime of the network is treated as a fit function. Then, through the selection, crossover, and mutation of each generation, the best offspring can be decoded as the best rule for each network model. Through the simulation, comparing with the existing routing protocols such as low-energy adaptive clustering hierarchy (LEACH), low-energy adaptive clustering hierarchy-centralized (LEACH-C), and stable election protocol (SEP), the EBRP prolongs the network lifetime (first node dies) by 57%, 63%, and 63%, respectively.