LONDON — Prime Minister David Cameron and his Conservatives won a resounding victory in the British general election, with complete results on Friday showing that the party had secured an overall majority in Parliament.

The vote was a stunning disappointment for the opposition Labour Party and its leader, Ed Miliband, who had shifted the party away from the more centrist strategy it pursued in the late 1990s and early 2000s under Tony Blair. Mr. Miliband stepped down on Friday, opening up a new debate over the party’s direction.

The result defied pre-election opinion polls that suggested a tight race between the Conservatives and Labour. It returns Mr. Cameron to 10 Downing Street for a second term, with enough seats in the House of Commons to act on his agenda without having to rely on support from smaller parties.

He went to Buckingham Palace on Friday for the formal step of being invited by the queen to form a new government.