When Dr. Nelson Bonheim first discovered that the new female physician hired by his medical practice was living with another woman, he was "a little uneasy about inviting her to his golf club," he recalled. Now, 25 years later, the 76-year-old retired gastroenterologist looks back on that uneasiness and thinks about how much he has evolved.

Bonheim said once he got to know his colleague, a lesbian 15 years his junior, they quickly became close friends. In fact, he said he eventually considered himself the younger doctor's "surrogate father or brother."

By the time his colleague married her female partner, Bonheim said he realized they “were like any other couple." He even spoke at her wedding, a wedding he said her own parents, who are Orthodox Jews, refused to attend because they didn’t fully accept her relationship.

“I was never opposed to same-sex marriage; people have a right to do what they want to do,” Bonheim added, "but I wasn’t as accepting as I am now.”

He said he and his former colleague, who's now in her 60s, still regularly have dinner with each other and their spouses.

Bonheim is not alone in evolving on LGBTQ rights and acceptance after befriending a gay person. A new study confirms what many have already known anecdotally: Having at least one gay or lesbian acquaintance not only makes straight people more likely to support gay rights, but also makes them more accepting of gay people in general.

The phenomenon is known as "contact theory," according to Daniel DellaPosta, the study's author and an assistant sociology professor at Pennsylvania State University. DellaPosta, who is gay, said he has both a "personal and academic interest" in the topic and was inspired to research it after finding data that showed acceptance of homosexuality grew five-fold between 1973 and 2016.

"I wanted to understand the sources of that drastic change," he told NBC News.

DellaPosta said his study, titled “Gay Acquaintanceship and Attitudes Toward Homosexuality: A Conservative Test," is the first to provide an empirical examination of how straight people are affected by tangential relationships with gay and lesbian people. In order to do this, he compared data from the 2006, 2008 and 2010 General Social Survey (GSS), which since 1972 has been gathering thousands of Americans' opinions on a range of social issues.

His analysis, which has since been published in the peer-reviewed journal Socius, found that “respondents who were acquainted with at least one gay or lesbian person in 2006 exhibited greater shifts toward increased acceptance of homosexuality and gay marriage in 2008 and 2010.”

In 2006, about 45 percent of people with a gay or lesbian acquaintance supported same-sex marriage, but by 2010 the figure had increased to 61 percent. Of the respondents who did not have a gay or lesbian acquaintance, only 22 percent approved of same-sex marriage in 2006. Four years later, just 18 percent of the same respondents supported gay marriage.

DellaPosta said he "wasn't surprised by the baseline findings" but rather by "who was changed" and how. He said his analysis showed that straight people with no gay friends who encounter a gay or lesbian individual superficially, like in a grocery store or on the subway, could have their prejudices "reinforced." But things change when you go one step further.

"If you take the next level to mere acquaintanceship — someone whose name you know, someone who, if you saw them on the street, you might stop and chat with them for a moment — the 'contact effect' sets in," he told NBC News. "When you suddenly have to interact with someone from an 'out group' as an individual, it forces you to reconsider your biases."

DellaPosta also found that while “older, politically conservative” straight people were the ones most likely to be against same-sex marriage in 2006, they were also the ones most likely to change their views on homosexuality and gay rights upon gaining a gay or lesbian acquaintance in subsequent years.

Liz Owen, a spokesperson for PFLAG, the first and largest organization for LGBTQ people, their family and allies, said “the data bears out what we’ve known anecdotally."

"Those who were previously opposed or ambivalent about gay and lesbian people can change their hearts and minds," Owen said.

A big “takeaway” from this study, according to DellaPosta, is that “coming out works as a strategy for changing minds.” This philosophy dates back to at least the beginning of the gay rights movement of the '60s and '70s and one of its pioneering leaders, Harvey Milk, whom DellaPosta said inspired his research.

Milk, who was assassinated in San Francisco 40 years ago, famously encouraged gay people to come out in a letter that was only made public after his death.

“I would like to see every gay doctor come out, every gay lawyer, every gay architect come out, stand up and let that world know," Milk wrote. "That would do more to end prejudice overnight than anybody would imagine. I urge them to do that, urge them to come out. Only that way will we start to achieve our rights."

DellaPosta acknowledged that not everyone who has a gay acquaintance will have a change of heart when it comes to gay people and LGBTQ rights. But, he added, "broadly speaking, it works."

FOLLOW NBC OUT ON TWITTER, FACEBOOK & INSTAGRAM