A crackdown by the People’s Bank of China on wagers against the yuan propelled the currency to its largest-ever two-day gain against the dollar, highlighting the rising tension in foreign-exchange markets over the outlook for China.

The Chinese central bank tightened liquidity in Hong Kong on Thursday and Friday by instructing the nation’s banks to withhold funds from other banks, a move that drove the yuan in offshore trading to its highest level since early November. The rate that banks charge each other in Hong Kong’s overnight...