This letter shows that optimizing the transmit powers along with optimally designed nonorthogonal pilots can significantly reduce pilot contamination and improve the overall throughput of the uplink multi-cell massive multiple-input multiple-output (MIMO) system as compared to the conventional schemes that use orthogonal pilots. Given the optimized nonorthogonal pilots, power control as a function of the large-scale path-loss can be thought of as a stochastic optimization problem due to the presence of fast fading. This paper advocates a deterministic approach to solve this problem, then further proposes a stochastic optimization method that utilizes successive convex approximation as a benchmark to quantify the performance of the proposed approach. Simulation results reveal significant advantage of using optimized nonorthogonal pilots together with power control to combat pilot contamination.