SEATTLE — Facebook and Google are under the microscope for the ways their technologies can spread misinformation, while Amazon’s growing market power is a regular target of President Trump. And Apple pioneered the modern smartphone, a device increasingly seen as too addicting.

Then there’s Microsoft, a giant that spent most of the 1990s and early 2000s as tech’s biggest company and villain. It now seems to be auditioning for a different role: the industry’s moral conscience.

Among the five most valuable tech companies, Microsoft is the only one to avoid sustained public criticism about contributing to social ills in the last couple of years. At the same time, Satya Nadella, its chief executive, and Brad Smith, its president, have emerged as some of the most outspoken advocates in the industry for protecting user privacy and establishing ethical guidelines for new technology like artificial intelligence.

On Monday, the conscientious side of Microsoft was on display again at Build, a three-day conference for developers in Seattle. Mr. Nadella announced a program, A.I. for Accessibility, that will award $25 million over five years to researchers, nonprofits and developers who use artificial intelligence to help people with disabilities. Mr. Nadella, whose adult son was born with cerebral palsy, has written about how his son’s disability helped make him more empathetic.

Echoing a theme he talked about at the conference last year, Mr. Nadella said the industry had a responsibility to build technology that empowered everyone.

Image

A screen from the Seeing AI app. David Yoffie, a Harvard business professor, said, “The irony for Microsoft is that they lost in search, they lost in social networks and they lost in mobile, and as a consequence, they have avoided the recent pushback from governments and media.”CreditKyle Johnson for The New York Times

“We need to ask ourselves not only what computers can do but what computers should do,” he said.

Microsoft’s new role is partly due to the fact that the company isn’t a major player in social media, video streaming and smartphones — the products behind the current dark mood around tech. It no longer squeezes the oxygen out of markets as Amazon can.

But while the company’s power has diminished since a couple of decades ago, when it controlled computing through Windows, Microsoft remains an influential voice. On Monday, its market capitalization of $733 billion made it the third most valuable technology company, behind Apple and Amazon and ahead of Google parent company, Alphabet, and Facebook.

“The irony for Microsoft is that they lost in search, they lost in social networks and they lost in mobile, and as a consequence, they have avoided the recent pushback from governments and media,” said David Yoffie, a professor at the Harvard Business School. “This has given Microsoft the freedom to take the high road as the ethical leader in technology.”

Since taking the reins at Microsoft in 2014, Mr. Nadella has brought a more sensitive style of leadership to the company than his two predecessors, Steve Ballmer and Bill Gates. That shift has proved to be more suitable for Microsoft in this era.

Two decades ago, Microsoft was depicted as a bully that ran roughshod over competitors in a landmark antitrust suit brought by the federal government, followed by similar cases brought by the European Union and private companies. Mr. Smith was brought in to make peace in Microsoft’s antitrust battles, and Mr. Nadella was the company’s first chief executive to start in the job since those suits were settled.

Image

“We need to ask ourselves not only what computers can do but what computers should do,” Satya Nadella, Microsoft’s chief executive, said on Monday at the company’s developer conference in Seattle.CreditKyle Johnson for The New York Times

In a phone interview, Mr. Smith, who is also Microsoft’s chief legal officer, called its legal problems in past decades a “gut-wrenching experience” that had shaped Microsoft in its current form. “It made Microsoft a better and more responsible company,” he said.

This year, Microsoft published a book that outlined some of the harmful effects that could come from artificial intelligence, such as bias in job recruiting. It has litigated four lawsuits against the United States government over the past five years in efforts to defend customers’ privacy rights. One of them, a fight over law enforcement access to data stored in an overseas Microsoft data center, went to the Supreme Court, which dropped the case after Congress enacted a law that mooted it.

“Not only did Microsoft learn from its mistakes, Satya is a unique and caring individual,” said Tim O’Reilly, a tech industry publisher and conference organizer. “He understands deeply that Microsoft must help others to succeed.”

The closest analog among Mr. Nadella’s peers is Tim D. Cook, the chief executive of Apple, who has painted Apple as a staunch defender of its customers’ privacy. He has jabbed at Facebook and Google, both advertising-supported businesses that profit from the personal data they collect from their users, a contrast to Apple’s business model of selling devices.

Facebook and Google, which owns YouTube, have defended their advertising businesses for allowing them to deliver services for free. They’ve promised to add more human moderators and invest in software tools that can screen out misinformation and other prohibited content.

Mr. Cook has not turned his ire toward Microsoft, which gets most of its revenue from software, hardware and cloud computing services. The company has investments in internet services that are supported in part by advertising, including its Bing search engine and LinkedIn, the social network for professionals it acquired in 2016.

Mr. Nadella has been more hesitant than Mr. Cook to publicly criticize other technology companies, turning to more subtle types of persuasion. A low-key leader, Mr. Nadella peppers his speeches and interviews with references to literature, warning that careless creators of technology could contribute to a dystopian world of George Orwell’s “1984” or Aldous Huxley’s “Brave New World.” His lieutenant, Mr. Smith, has become a ubiquitous ambassador for Microsoft on the big social issues facing technology in Washington, in Brussels and on the conference circuit.

Microsoft is still occasionally cast in the role of villain. A California man who sold recycled electronic waste recently pleaded guilty for creating thousands of unauthorized discs that helped people restore the Windows operating system on refurbished PCs. The recycler, who has been sentenced to 15 months in prison, has said Microsoft supported the case against him, which was brought by federal prosecutors, because he threatened part of its business. Microsoft published a long blog post that portrayed his actions unfavorably.

Still, the Microsoft of 2018 is a long way from the company that was once portrayed as a corporate predator.

“Microsoft lived through negativity that these companies are experiencing now, and it doesn’t want to go back to those days,” said Vivek Wadhwa, a distinguished fellow with Carnegie Mellon University’s Silicon Valley campus.

Mr. Smith of Microsoft said the greater scrutiny on the tech sector would not always fall on the same companies.

“At any given moment, there may be one or two companies in the spotlight,” he said. “I don’t think one should assume the same one or two are always going to be in the spotlight or always on the defensive.”

A version of this article appears in print on , on Page B3 of the New York edition with the headline: Microsoft, Long Seen as Villain, Tries on Role as Moral Leader. Order Reprints | Today’s Paper | Subscribe