LONDON—For British Prime Minister Theresa May, what looked like a sure thing is starting to look more like a gamble.

When she called an election on April 18, some opinion polls showed her Conservative Party leading the main opposition Labour Party by more than 20 percentage points. That would have expanded her working majority in the House of Commons from 17 seats to as many as 150.

Just...