Device-to-device (D2D) communication is an essential part of the 5G system used in cellular networks, which enables devices to communicate with each other without passing the base station BS. It is likely to aid in satisfying increasing capacity and effectively offloading traffic from the BS by distributing the transmission between D2D users from one side and cellular users and the BS from the other side. It results in improved throughput, energy efficiency, and other parameters. At the same time, the introduction of D2D communication in cellular networks creates new technical challenges to be addressed. One of the major issues is the mitigation of interference between device users (DUs) and primary users (PUs). This issue leads to performance degradation if it is not managed properly. In this paper, an intelligent distributed channel selection framework (IDCSF) in D2D communication for 5G networks with hybrid selection modes of D2D is proposed to help DUs select the best channel for transmission to mitigate interference. This channel selection framework classifies the available sensed channels using self-organizing map (SOM) learning technique into four classes considering channels with sensing errors false alarm (FalsA) and miss detection (MissD) to prevent using occupied channels. Furthermore, PU activity model is adjusted to aid in recovering from bad channel selection decisions. Moreover, fuzzy logic technique is utilized to determine the reliable channels which can help the DU along with channel selection algorithm to find channel’s weight values. The channel with highest weight value is selected as the best channel. Simulation results show that the proposed framework IDCSF enhances selecting the best channel, improves throughput and spectral utilization, and reduces average delay, interference and search time compared to other approaches.