Kevin Spacey, a two-time Oscar winner, apologized Sunday night for what he said “would have been deeply inappropriate drunken behavior” after the actor Anthony Rapp made an accusation about his sexual conduct with him 31 years ago, when Mr. Rapp was 14 years old.

Mr. Spacey, who has long been fiercely private about his personal life, said in a statement that he did not remember any such encounter, but added that Mr. Rapp’s accusation “has encouraged me to address other things about my life.” He then disclosed that he had “loved and had romantic encounters with men throughout my life, and I choose now to live as a gay man.”

The rapid cycle of accusation and apology began Sunday evening, when BuzzFeed published an article in which Mr. Rapp alleged that Mr. Spacey “was trying to get with me sexually” after a party at Mr. Spacey’s apartment in 1986. After all the other guests had left, Mr. Rapp said that Mr. Spacey, who appeared intoxicated, “picked me up like a groom picks up the bride over the threshold. But I don’t, like, squirm away initially, because I’m like, ‘What’s going on?’ And then he lays down on top of me.”