KARACHI, Pakistan—When Prime Minister Nawaz Sharif came to office in 2013, rolling power outages across the country were plunging homes and businesses into darkness for up to 12 hours a day.

Now the Pakistani leader is betting on a $21 billion Chinese-backed splurge on energy projects to boost the economy—and his re-election bid.

More than...