Mayor Bill de Blasio is certainly not the only elected official who has been critical of efforts to legalize recreational marijuana, only to slowly change his position over time.

But Mr. de Blasio said that his gradual shift — memorialized on Thursday at a news conference where he announced his support for legalization, with some caveats — did not come simply because other states had done so, or because of the revenue it could bring.

The mayor said that his family’s experiences with addiction, including growing up with a father who was addicted to alcohol and cigarettes, compelled him to make sure that New York City took enough precautions before embracing legalization.

“You can’t take addiction lightly when you’ve seen it,” Mr. de Blasio said in Washington Heights.

The mayor’s father, Warren Wilhelm, lost his leg during battle in World War II. After Mr. Wilhelm was investigated for being a Communist sympathizer, his health deteriorated over the years while using alcohol.

Toward the end of his life, Mr. Wilhelm developed lung cancer and emphysema from smoking and refused to seek help for his drinking problem. He committed suicide in New Milford, Conn., in July 1979, by shooting himself in the chest with a rifle.

The mayor, who said that he tried marijuana in college but has not used it since, said that he was not equating marijuana and alcohol use, and felt that alcohol abuse could be more dangerous in many ways.

Mr. de Blasio’s announcement on Thursday came three days after Gov. Andrew M. Cuomo, who only recently called marijuana a “gateway drug,” announced his support for legalizing recreational use of the drug.

Mr. de Blasio acknowledged receiving pressure from activists who pushed him to this position, as well as from his wife, Chirlane McCray, who announced months ago that she favored marijuana legalization.

Ms. McCray also talked about how her personal experience with marijuana shaped her viewpoint.

“I know from my own experience that it can be habit-forming,” said Ms. McCray, who leads a citywide mental health initiative.

Ms. McCray told Observer in March that she had to seek therapy because she had difficulty trying to stop smoking marijuana. On Thursday, Ms. McCray expressed concern that marijuana could become addictive, especially in young people.

“That’s something I think about all the time: that anything we do we’d better be damn certain we’re not accidentally opening up a dynamic where more people will suffer,” Mr. de Blasio said.

Ms. McCray said that she believes in legalization but that “it’s not without risk.”

“What are the public health consequences and who would profit?” she asked.

As part of the mayor’s announcement, the city issued a report talking about ways to deal with racial disparities in marijuana arrests and making sure that corporations do not dominate legal marijuana production. The mayor said that the people who had “suffered from the war on drugs” should “benefit economically” from marijuana legalization.

Councilman Ydanis Rodriguez of Upper Manhattan said that legalizing marijuana is personal to him because he has seen the lives of too many African-Americans and Latinos ruined as a result of being arrested on charges of using or possessing marijuana.

“Marijuana has been practically legal for the upper class,” Mr. Rodriguez said. “Unless you are black, Latino or poor, you will never understand the importance of this day,” he added.

The former City Council speaker, Melissa Mark-Viverito, who is running for public advocate and has long called for marijuana legalization, said she was not “callous” to the mayor’s discussion of how his father’s addiction had made him cautious about legalization. But, she said, “that sense of deliberation is not something that I feel has been going on with the mayor in all the times he pushed back on this.”

Iesha Sekou, chief executive and founder of Street Corner Resources, a Harlem group that works to prevent gun violence, said she was happy the mayor had finally arrived at supporting marijuana legalization. Every year she deals with young people who lose opportunities to go to school or get jobs because of marijuana-related arrests.

“There is a difference between your personal feelings and what’s actually happening to people,” Ms. Sekou said. “He’s coming from a hard place. He had to give it a lot of thought.”

A version of this article appears in print on , on Page A25 of the New York edition with the headline: De Blasio, Explaining His Caution on Marijuana, Cites Painful Family History. Order Reprints | Today’s Paper | Subscribe