SAN FRANCISCO — Google on Monday fired a software engineer who wrote an internal memo that questioned the company’s diversity efforts and argued that the low number of women in technical positions was a result of biological differences instead of discrimination.

The memo, called “Google’s Ideological Echo Chamber,” angered many in Silicon Valley because it relied on certain gender stereotypes — like the notion that women are less interested in high-stress jobs because they are more anxious — to rationalize the gender gap in the tech industry. The memo quickly spread outside the company, as other Google employees railed against many of its assumptions.

In a companywide email, Google’s chief executive, Sundar Pichai, said portions of the memo had violated the company’s code of conduct and crossed the line “by advancing harmful gender stereotypes in our workplace.”

The memo put the company in a bind. On one hand, Google has long promoted a culture of openness, with employees allowed to question senior executives and even mock its strategy in internal forums. However, Google, like many other technology firms, is dealing with criticism that it has not done enough to hire and promote women and minorities.