The prime minister chose the ground on which the local election campaign was fought — and is now paying the price