Massive multiple-input multiple-output (MIMO) has been viewed as an advanced technique in future 5G networks. Conventional massive MIMO systems consist of cellular base stations (BS) equipped with a very large number of antennas to simultaneously serve many single-antenna users. Unfortunately, massive MIMO system’s performance is limited by pilot contamination (PC) problem. Conventionally, all users in massive MIMO systems are assigned pilot randomly. In this paper, we propose a pilot allocation algorithm based on a cell with the worst channel quality (WCPA) algorithm to improve the uplink achievable sum rate of the system. Specifically, WCPA exploits the large-scale coefficients of fading channels between the BSs and users. According to the number of available orthogonal pilot sequences, we choose some of the highest inter-cell interfering users and assign each of them a unique pilot sequence if the number of pilot sequences is more than the number of users in a cell. Next, we choose a target cell with the worst channel quality, and gather the highest channel gain user in the target cell and the lowest interfering user in the other cells in the same group in a sequential way by assigning them the same pilot sequence. The simulation results show the outperformance of the proposed algorithm compared to the conventional pilot allocation schemes.