LONDON—Boris Johnson assembled a team of mainly euroskeptic ministers to prepare an all-out push to get the U.K. out of the European Union, replacing more than half of his predecessor’s cabinet as he took over as British prime minister.

In a sign of the brinkmanship to come, Mr. Johnson on Wednesday handed key roles, including that of foreign secretary and home secretary, to loyalists who have said they are unafraid to abruptly exit the EU by the Oct. 31 deadline without a divorce deal.

In...