Spacey said in a post on Twitter he was horrified to hear Rapp's story of the encounter, which he said he did not remember. He wrote that he owed Rapp a "sincere apology" for what he said would have been "deeply inappropriate drunken behavior."
In an interview with BuzzFeed, Rapp described attending a party hosted by Spacey in which the actor picked him up, brought him to a bed and lay down on top of him after other guests left.
Rapp, who said he had the impression Spacey was drunk, pushed him away and left.
Spacey, 58, who has won Oscars for "The Usual Suspects" and "American Beauty," also said Rapp's story "has encouraged me to address other things in my life."
"I have loved and had romantic encounters with men throughout my life, and I now choose to live life as a gay man," Spacey wrote.
"I want to deal with this honestly and openly," he said, "and that starts with me examining my own behavior."
The actor for years had declined to address rumors about his sexuality.
Spacey, a Tony Award winner for "Lost in Yonkers," stars in the Netflix political drama "House of Cards." He also served for 10 years as artistic director of London's Old Vic theater company.
Hollywood and some top US companies have been rocked in recent weeks by allegations from scores of women that executives had sexually harassed them.
US movie mogul Harvey Weinstein has been accused by numerous women of having sexually harassed or assaulted them in incidents dating back to the 1980s, including some who said they were raped.
Weinstein denies having non-consensual sex with anyone. He has since been fired as chief executive of The Weinstein Company, which he co-founded and has which been one of Hollywood's most influential forces since its launch in October 2005.
(Except for the headline, this story has not been edited by NDTV staff and is published from a syndicated feed.)