WASHINGTON — A few hours before President Obama offered his historic endorsement of same-sex marriage on Wednesday, Vice President Joseph R. Biden Jr. apologized to the president in the Oval Office for forcing Mr. Obama’s hand by airing his own views three days earlier, several people briefed on the exchange said on Thursday.

Mr. Biden declared in an interview on Sunday that he was “absolutely comfortable” with same-sex marriage, a position that went considerably further than the president’s “evolving” views on the matter and scrambled the White House’s carefully laid plans for confronting one of the most sensitive social issues in the election.

Mr. Obama, in an interview with ABC News, said the vice president had gotten “a little bit over his skis” but had done so “out of generosity of spirit.” The president bore Mr. Biden no lingering ill will, according to several officials, though the episode enraged Mr. Obama’s senior advisers in the White House and on the campaign.

It was easily the biggest incidence of crossed wires between the garrulous vice president and his more button-down boss, in an administration that has been marked by occasional eruptions by Mr. Biden. And its effect was magnified both because it involved a fraught social issue and because it came just as the general election campaign is heating up.