Timothy D. Cook, Apple’s chief executive, said he was “proud to be gay” in an essay published early Thursday, becoming by far the most prominent executive of a public company to come out.

“Let me be clear: I’m proud to be gay, and I consider being gay among the greatest gifts God has given me,” Mr. Cook wrote in the essay, published by Bloomberg Businessweek.

Mr. Cook, 53, has never spoken publicly about his sexual orientation in the many years he has worked in the spotlight at Apple.

In his essay, Mr. Cook also noted that he had spent much of his life trying to keep his personal matters private, which is why he had not previously spoken in public about his sexual orientation.

“Apple is already one of the most closely watched companies in the world,” he wrote, “and I like keeping the focus on our products and the incredible things our customers achieve with them.”

While he has never talked about it publicly, Mr. Cook’s sexuality has been a widely open secret in Silicon Valley. In private forums, he has alluded to facing difficulties growing up as a young man in Alabama, where he was raised for much of his childhood. He has said that human rights and dignity are values that need to be acted upon.

With his essay, Mr. Cook becomes the most prominent gay man in the corporate world, joining a very short list of openly gay executives at public companies. He also defies corporate sexual identity norms; 83 percent of gay, lesbian and bisexual people hide aspects of their identity at work, according to a Deloitte report.

Silicon Valley, and technology companies in particular, have taken largely progressive stances on gay rights and advancement in the workplace. Companies like Google, Facebook and Apple participate regularly in San Francisco’s annual gay pride parade. And many of these companies, including Twitter, Intel and Apple, offer more inclusive health benefits packages to gay employees and their partners.

Activist groups were quick to praise Mr. Cook for his essay, while lauding Apple’s progressive history. “Tim Cook’s announcement today will save countless lives,” the Human Rights Campaign, America’s largest lesbian, gay, bisexual and transgender civil rights group, said in a statement. “He has always been a role model, but today millions across the globe will draw inspiration from a different aspect of his life.”

As Apple’s chief executive, he has publicly pushed for marriage equality in its workplace, and had consistently enacted progressive policies to encourage gay, lesbian, bisexual and transgender candidates to work for the company.

Apple has publicly supported a workplace equality bill in California, site of the company’s headquarters, and spoke against a bill passed in Arizona which Apple said discriminated against the gay community.

Mr. Cook recently gave a speech in Alabama, in which he denounced his home state’s history of human rights and addressed its record of inequality for lesbian, gay, bisexual and transgender individuals.