Boris Johnson's gamble on early elections paid off as voters gave the UK prime minister a commanding majority to take the country out of the European Union by the end of January, a decisive result after more than three years of stalemate over Brexit.