WASHINGTON — Shortly before President Barack Obama voiced his support for gay marriage, Vice President Joe Biden apologized to the president for comments that led him to speed up his public pronouncement.

Biden and Obama spoke in the Oval Office on Wednesday, a person familiar with the exchange said, speaking on condition of anonymity to discuss the private talk. Obama accepted his vice president's apology, saying he knew Biden was speaking from his heart when he declared in a television interview that he was "absolutely comfortable" with gay couples marrying.

Biden's comments pushed gay marriage to the forefront of the presidential race and focused a fresh spotlight on Obama's vague position on the matter. The president, who once opposed gay marriage, had been saying for more than a year that his personal views were "evolving."

The vice president spoke out on gay marriage without White House consent, leaving Obama aides deeply frustrated.

In an interview with ABC News, Obama said he wasn't angry at Biden, though he thought the vice president had gotten "a little bit over his skis" by voicing his support for gay marriage ahead of his boss.

"Would I have preferred to have done this in my own way, in my own terms, without I think, there being a lot of notice to everybody? Sure," Obama said. "But all's well that ends well."

By the time Biden's interview on NBC's "Meet The Press" aired on Sunday morning, a handful of close Obama aides knew that the president had already finished that evolution. He had decided to speak publicly about his personal support for gay marriage sometime before the Democratic convention in early September.

The White House and Obama's presidential campaign at first tried to play down Biden's remarks, insisting that the vice president had gone no further in support of equal rights for same-sex couples. But gay rights advocates latched onto Biden's remarks, declaring him the highest-ranking U.S. official to support gay marriage.

Education Secretary Arne Duncan, a longtime friend of the president, stirred the political pot further on Monday, declaring unequivocally that he also supported gay marriage.

By Tuesday morning, the president came to the conclusion that he couldn't stay silent on the issue any further. The White House hastily arranged a television interview with ABC News for Wednesday, during which Obama explained to the public that he had decided it was important for him to "affirm that same-sex couples should be able to get married."