Procter & Gamble Co. is clawing its way out of a hole in China as it and other global consumer-products companies struggle to make sense of the critical but increasingly tough market.

Global makers of products from diapers to toothpaste have been hit by a trifecta in China of slower consumer spending, heightened competition and a rapid shift toward online shopping. The dynamics have triggered a price war in the country and are taking a bite out of earnings for companies such as P&G, Colgate-Palmolive Co. and Unilever...