Particle swarm optimization (PSO) is a stout and rapid searching algorithm that has been used in various applications. Nevertheless, its major drawback is the stagnation problem that arises in the later phases of the search process. To solve this problem, a proper balance between investigation and manipulation throughout the search process should be maintained. This article proposes a new PSO variant named two-phases PSO (TPPSO). The concept of TPPSO is to split the search process into two phases. The first phase performs the original PSO operations with linearly decreasing inertia weight, and its objective is to focus on exploration. The second phase focuses on exploitation by generating two random positions in each iteration that are close to the global best position. The two generated positions are compared with the global best position sequentially. If a generated position performs better than the global best position, then it replaces the global best position. To prove the effectiveness of the proposed algorithm, sixteen popular unimodal, multimodal, shifted, and rotated benchmarking functions have been used to compare its performance with other existing well-known PSO variants and non-PSO algorithms. Simulation results show that TPPSO outperforms the other modified and hybrid PSO variants regarding solution quality, convergence speed, and robustness. The convergence speed of TPPSO is extremely fast, making it a suitable optimizer for real-world optimization problems.