John N. McMahon, the Central Intelligence Agency deputy director who has opposed the Reagan administration's expansion of covert paramilitary operations in Third World conflicts, is resigning from the agency, the White House announced yesterday.

The announcement said that Robert M. Gates, 42, the CIA's deputy director for intelligence, would take over from McMahon, 56, who it said is resigning "for personal reasons" after 34 years with the agency.

In a Feb. 24 letter to President Reagan, McMahon said he thought he had "reached a stage where I should move on" despite "mixed emotions" about leaving the agency. His resignation is effective March 29.

Administration sources said McMahon made his decision last week as an interagency group in charge of covert operations decided on a significant escalation of four paramilitary operations. The sources would not specify the countries involved but indicated that they were mentioned in recent administration statements -- Afghanistan, Nicaragua, Angola and Cambodia.

McMahon was known in particular for questioning the U.S. policy of growing involvement in, and support for, anticommunist insurgencies in Nicaragua and Afghanistan.

The departure of McMahon -- who came up through the ranks, worked in the U2 spy plane program in the early 1960s and later headed the agency's clandestine service -- clears the way for a more activist policy of CIA intervention that the agency's director, William J. Casey, has been promoting.

McMahon opposed increased U.S. involvement in Third World conflicts that he believed could not be politically sustained at home over a long period. To many both in and outside the CIA, he has become the agency's conscience, seeking to protect it from the kind of controversial activities and "dirty tricks" that led in the mid-1970s to scandal, public criticism and painful congressional investigations.

McMahon's opposition to CIA paramilitary operations was mostly played out inside the agency, to which he is intensely loyal. But in one unusual episode in the spring of 1980, sources said, McMahon wrote a classified memorandum to President Jimmy Carter arguing against covert support for Afghan rebels opposing the Soviet invasion of Afghanistan in December 1979.

McMahon took a similar position in opposing the expanding U.S.-backed paramilitary operation against the Sandinista government in Nicaragua. Sources said he was on the losing side in the battle to prevent the president and his top national security affairs advisers from requesting an unprecedented $70 million in covert military aid to reinvigorate the antigovernment rebels fighting the Sandinistas from bases in Honduras.

One source said McMahon was distressed that this year the CIA had passed a milestone at which the agency's budget for covert operations surpassed that for traditional espionage and clandestine collection of intelligence.

Moreover, McMahon was described as "increasingly testy" over the growing role of the Defense Department in developing its paramilitary capabilities for covert operations, a development he viewed as an encroachment on the CIA's turf. A legislative proposal now circulating in congressional offices would establish a $500 million "freedom-fighter" fund under the control of Richard N. Perle, assistant secretary of defense for international security policy.

McMahon's stand against expanding CIA paramilitary activities because of what he regarded as a long-term threat to the agency's traditional functions of intelligence collection and analysis earned him the ire of conservative political action groups, which launched a campaign last October to have him ousted.

John Houston, vice president of Free the Eagle, which with the Federation for American-Afghan Action led the campaign, said that "over 10,000" letters demanding McMahon's resignation had been sent to the White House.

"We take credit for this," Houston said.

The two groups have been pressing for an appointment with White House chief of staff Donald T. Regan, and one administration source said he has agreed to a meeting.

Despite his well-known policy differences with Casey, in his letter of resignation McMahon went out of his way to praise the CIA director as "a unique asset" who brought "wisdom, energy and leadership" to the agency and "provided our country with an intelligence capability second to none."

"While I admit that I do not leave the intelligence world without mixed emotions," McMahon wrote, "it is gratifying to leave it on a high and in such good hands."

Gates, McMahon's successor, is a specialist in Soviet studies who served in the late 1970s as chief intelligence officer on the National Security Council. While personally close to Casey, Gates is not thought to have experience in covert operations.

A CIA employe since 1966, he has served mostly as a senior analyst and administrator and has been involved publicly in the agency's recent attempts to reestablish its ties with the academic community.