Two hostile teams of high-ranking Secret Service officials are skulking through Washington, using code names, meeting in out-of-the-way places to avoid detection by the other side, each hoping to thwart the other's desire to take control of the organization.

In recent weeks, the top management of the usually apolitical Secret Service has been torn apart in a bitter struggle in which the Reagan administration has dictated that Director H. Stuart Knight will report to the parent agency, the Treasury Department, through Robert E. Powis. Powis is a former assistant director of the Secret Service whom Knight tried to force into retirement and who, not surprisingly, is Knight's most vociferous critic, according to both Treasury Department and White House sources.

Knight and a cadre of suporters have been trying to prevent the controversial Powis' appointment as deputy assistant secretary of the treasury for enforcement, the office to which Knight reports daily. Powis' permanent appointment, Knight has told his superiors in treasury, would place the agency under the control of an unqualified political operative responsive to the White House.

This, Knight's allies say, could lead to the very situation that Knight was brought in to cure -- the Watergate scandal revelation that Nixon administration officials used high-ranking Secret Service officials they had promoted to spy on other presidential candidates during the 1972 campaign.

All parties agree that the most influential force behind Powis' appointment was the personal endorsement of two highly influential friends: presidential counselor Edwin Meese III and Edward V. Hickey Jr., the former Secret Service agent and Reagan security man who now heads the White House military liaison office.

White House officials insist that Powis is an exceptional law enforcement officer who is the victim of a calculated character assassination by jealous rivals. According to Powis' supporters, he is an effective leader who will be more responsive to the needs of agents in the field than the more bureaucraticlly oriented Knight.

Knight's loyalists reply that he has modernized and professionalized the service's administrative operations while keeping it aloof from partisan politics.

Knight does not intend to resign while he is in good health, according to sources close to him. But the Powis appointment still represents the first time in a decade that a Secret Sevice official has used the White House to advance his career, the sources say.

"That is a total misunderstanding," says Hickey. "This is not a Secret Service appointment, but an appointment to the Department of the Treasury. The only thing they [the Treasury Department] asked us [meese and Hickey] was did we endorse Powis. I endorse him totally and would do so wholeheartedly in the future."

"If anything," Hickey continued, "everyone in the Secret Service should be elated that one of their own finally achieved a position with status above that of the director of the Secret Service."

But the prospect of Powis' new authority instead has almost evenly divided the top echelons of the Secret Service into a Knight camp, which includes Deputy Director Myron (Mike) Weinstein, and a Powis camp that incudes John R. Simpson, the assistant director for protective operations. Simpson and Weinstein are leading contenders to eventually assume the director's job, along with Powis, who reportedly would prefer it to the Treasury job.

Also as a result of the conflict, two rival groups of senior executives and career agents -- the men who throw themselves in front of assassins' bullets -- are arranging secret rendezvous with colleagues, Capital Hill aides, and reporters, for fear of discovery and retribution should their side lose.

When Powis first surfaced for the treasury job shortly after the change in administrations, Knight complained to Deputy Treasury Secretary R.T. McNamar and John M. Walker, Reagan's nominee for assistant treasury secretary for enforcement and operations, that appointing Powis over him after he had demoted Powis for insubordination would undercut his; authority.

Simultaneoulsy, a series of allegations about Powis' involvement in improprieties reached treasury officials, department sources said. The officials put a freeze on the appointment while they investigated.

Walker's predecessor from the Carter administration, Richard Davis, told him that he believed that Powis was fully qualified for the treasury job and that Powis would not politicize the agency. But Davis also warned that lingering questions about the intentions of the White House in such an internal dispute could stigmatize the Secret Service, dividing it permanently into two warring factions.

The conflict between Knight and Powis began sometime after 1977 when Knight promoted Powis from special agent in charge of the Los Angeles office to assistant director for protective operations.Associates of Knight say that Powis had a reputation for strong will and independence from Washington headquarters that had earned his Los Angeles field office the nickname "Headquarter -- West Coast."

Knight's and Powis' first serious clash occurred in 1979 after Powis became assistant director for investigation. They differed on how far the Secret Service should go in seeking new jurisdiction over such matters as bank fraud and stolen securities, which had been under the jurisdiction of the FBI.

Walker found that the most serious accusation against Powis was that an investigation last year disclosed that when Powis had been SAC of the Los Angeles office, he had misused funds earmarked for confidential informants.

According to sources familiar with the investigation, Powis submitted government vouchers seeking reimbursement to the Los Angeles office for funds to buy counterfeit money. In fact, he used the funds to pay a $10-per-day meal allowance to agents required to stay in the city overnight on double protective coverage shifts.

Although no one alleged that Powis had profited from the transaction, he acknowledged that he had knowingly submitted the vouchers to disguise the true use of the money, because he knew that federal regulations prohibited reimbursement of meals for agents not stationed away from home. His obstincy made him a hero among many agents in the field, but harmed his reputation as a team player in Washington.

Although Knight reportedly did not hold the voucher incident against Powis, he concluded that Powis was incorrigibly insubordinate and decided to demote him to assistant special agent in charge of the New York field office. Davis thought the transfer too severe, but approved it because to do otherwise would have been tantamount to asking Knight for his resignation.

Powis struck a deal with Knight under which he became head of the Washington field office with the understanding that he would retire in the fall of 1980, after the investigation of his alleged misuse of funds was completed.

However, when Powis' retirement papers did not come in the fall, Knight again tried to force Powis out, but Powis reportedly said that he intended to await the results of the presidential election.

Sources said that McNamar and Walker at this point were told by the White House in no uncertain terms that Powis was to get the treasury job.

Two well-placed treasury sources said that after the investigation, McNamar and Walkerwere satisfied that Powis was exonerated and would make fair and nonpolitical decisions. Meese had called several times on his behalf, one source said, but only to check on the progress of the nomination.

Treasury Department sources say that Walker, who is a first cousin of Vice President Bush and who has yet to be confirmed, will not give Powis a blank check to run the Secret Service. Powis' appointment does not become permanent until Walker is confirmed and the question of his authority will be explored at Walker's confimation hearings.