Michael K. Deaver launched a counteroffensive against his critics yesterday, asserting that he is the victim of politically motivated, "mean-spirited" attacks that implicitly question the integrity of his longtime friend and former boss, President Reagan.

In an opening statement to a House subcommittee investigating his lobbying activities, Deaver said he has "absolutely never taken advantage" of his friendship with the president and First Lady Nancy Reagan. He insisted that he had "consistently sought to maintain a high standard of integrity" in his business dealings since leaving his post as White House deputy chief of staff a little over a year ago.

"I do not believe that my friendship with them is either a commodity to be exploited by me or a legitimate basis for my being hounded in the press or anywhere else," he said. "In my view, the suggestion that after 20 years of selfless service I would suddenly begin to use that relationship for personal gain is not only mean-spirited but is also an implicit attack on the integrity of the president."

Deaver testified under oath for more than five hours yesterday in a closed session of the House Energy and Commerce subcommittee on oversight and investigations. A copy of his opening statement was made public.

He is to continue testimony to the subcommittee at least one more day, but a date has not been set.

During a break in yesterday's hearing, committee Chairman John D. Dingell (D-Mich.) said Deaver had been questioned about the representation of Canada and other foreign governments by his lobbying and public relations firm, Michael K. Deaver & Associates. Dingell said Deaver also was questioned about a General Accounting Office report that said Deaver may have violated federal conflict-of-interest laws by signing a $105,000-a-year contract with Canada centering on the issue of acid rain. Deaver dealt with the subject extensively as a White House official.

The committee is seeking to determine not only whether any laws have been violated, but whether existing laws are sufficient "to assure the highest moral and ethical standards of those who serve in government and during the time after they leave," Dingell said.

"Those standards should be the highest possible, and obviously the tone of every administration is set by those who leave it," he continued. "I can personally observe that there are some questions here about whether the tone is of the highest level and the kind sought by the American people at this time."

Dingell added, "Mr. Deaver's testimony today has been interesting, and he has been helpful. But the subcommittee's investigation is far from complete."

Subcommittee members declined to discuss details of Deaver's testimony, but several indicated dissatisfaction with his answers. They also suggested that they will push to make federal conflict-of-interest and lobbying laws, including the Foreign Agents Registration Act, more stringent. Under that act, Deaver was able to begin lobbying for several foreign governments immediately after leaving the White House.

"I am concerned that the message is that public service can be turned into big bucks," said Rep. Ron Wyden (D-Ore.), who chaired the afternoon session after Dingell left for Michigan. He said government officials "owe a greater obligation to the public than just avoiding committing felonies."

Rep. Thomas A. Luken (D-Ohio) noted "the apparent inability of Mr. Deaver to distinguish between public service and his consulting service."

Characterizing Deaver's attitude as "pretty close to saying 'trust me,' " Luken said, "He sees nothing wrong in helping foreign governments in getting around our country."

Rep. John Bryant (D-Tex.) said, "Most important, this inquiry has highlighted the fact that it is legal today -- unbelievably so -- for the closest adviser to the president of the United States to go to work for foreign governments immediately after he leaves the White House."

Deaver's appearance before the subcommittee, conducted in private by agreement between him and Dingell, was only part of his carefully orchestrated counteroffensive. Immediately after the hearing, Deaver was scheduled to hold interviews with several major newspapers and the three main television networks.

The interviews, however, were postponed until after Deaver completes his closed-door subcommittee testimony.

Known at the White House for his mastery of public relations techniques that are thought to have boosted Reagan's popularity, Deaver yesterday put his skills to work in his own behalf. Wearing a dark blue suit and smiling, Deaver arrived with two aides at the Rayburn House Office Building in a modest American car rather than the chauffeur-driven Jaguar he frequently uses.

Deaver stopped briefly before reporters and television camera crews and three times delivered slightly different versions of his message: "After five months of leaks, rumors and innuendo, today is my turn."

"There is no question in my mind about violating the law," Deaver told reporters after his testimony. "I have followed the law as written by this Congress and Congresses for 60 years."

He said it was "an insult to my clients and to me" to suggest that his lucrative lobbying and consulting business is based only on his close ties to the Reagans, and he repeated his charge that some of the allegations raised against him are "politically motivated and outrageous."

He would not say which allegations he had in mind.

Deaver's opening statement did not deal with any of the specific questions that have been raised about his conduct since leaving the White House. Instead, he portrayed himself as someone who for almost 20 years had given his "total commitment" to Reagan and "the tradition of public service," and is being subjected to "misinformed allegations of unnamed critics in the press."

Deaver devoted much of his statement to a defense of his firm's representation of foreign governments. He said his foreign clients are "strong allies of the United States" and that his firm's services could help strengthen their ties to this nation.

Denying that these and other clients came to him because of "my relationship with the Reagans," Deaver said that if there is dissatisfaction with the Foreign Agents Registration Act as passed by Congress, "then such criticism should be directed to Congress, not to individual citizens."

"I would also like to state that I have never traded on my relationship with the president for any client -- and I never will," Deaver said.

Seven of the subcommittee's 18 members, including one Republican, Rep. Michael G. Oxley (Ohio), attended the opening session yesterday morning. In the afternoon, three subcommittee members, all Democrats, heard Deaver continue his testimony.