WASHINGTON—House Speaker John Boehner, bowing to heavy pressure from fellow Republicans, agreed Thursday to a two-month extension of a payroll-tax break, ending a stalemate that had created a wedge within the party.

The deal, which forestalls a Jan. 1 tax increase on 160 million workers, represents a retreat for the House GOP, which had been at odds with Senate Republicans and party elders who feared the party would suffer in the 2012 elections if the tax break was allowed to expire.

The...