The need for significant improvements in the management and efficient use of electrical energy has led to the evolution from the traditional electrical infrastructures towards modern Smart Grid networks. Taking into account the critical importance of this type of networks, multiple research groups focus their work on issues related to the generation, transport and consumption of electrical energy. One of the key research points is the data communication network associated with the electricity transport infrastructure, and specifically the network that interconnects the devices in consumers' homes, the so-called Neighborhood Area Networks (NANs). In this paper, a new fair and distributed congestion control mechanism for NANs is proposed, implemented and evaluated. The main goal of this mechanism is to provide fairness in the access to the network, thus avoiding that some network nodes monopolize the use of the channels due to their higher traffic generation rate, or to their geographical position. Besides, different priorities have been considered for the traffic flows transmitted by different applications. The goal here is to provide the needed Quality of Service (QoS) to all traffic flows, especially when the traffic load is high. The proposal is evaluated in the context of a wireless ad hoc network composed by a set of smart grid meter devices. Applying our proposed congestion control mechanism leads to performance improvements in terms of packet delivery ratio, network throughput fairness between different traffic sources, packet network transit time and QoS provision.