H. Patrick Swygert, the first "public defender" of bureaucratic whistle blowers and one of the top-ranking blacks in the administration, has resigned effective Friday. He will return to the Temple University law school staff and campaign for President Carter in Pennsylvania.

Swygert's letter to the president cited "personal reasons" for leaving as special counsel of the Merit Systems Protection Board. The job, created in January, has become a political-media hotseat.It has won Swygert generally good reviews, but also attracted some powerful enemies in departments and agencies that have had their knuckles rapped for attempting to gag, exile or can employes for pointing out illegal, or dumb, actions.

A union leader who has sometimes crossed swords with Swygert said he "got good marks at the White House. But there are a lot of political types around who will be happy to see him go. He took the job too seriously -- for them."

The 36-year-old lawyer came here in 1977 as general counsel for the old Civil Service Commission. He helped with Carter's Civil Service Reform Act, one of the few legislative victories for the White House in 1978.

The law abolished the CSC. It created several new agencies designed to provide independent investigation, and judgment, of whistle blowers' complaints. Swygert was the first person to head the office of special counsel which has taken on about 1,700 cases in its first 11 months of life.

Under the new system, the office of special counsel investigates charges of reprisals or illegal job actions. And it defends employes against bosses or entire departments. The counsel recommends action to the Merit System Protection Board. MSPB has the final say so on what happens in each case.

Almost from their creation -- partly because of different missions, and different personalities at the top -- there has been bureaucratic warfare between Swygert's office and the MSPB hierarchy right across the hall. Ruth Prokop, a Texan who served on Lyndon B. Johnson's vice presidential staff and later was general counsel of the Department of Housing and Urban Development, heads the MSPB.

Some MSPB aides considered Swygert "too aggressive" and a power grabber who liked to see his name in the newspapers. The board, on the other hand, is viewed by many as being too sympathetic to top management, and unwilling to slap down a powerful department -- or its boss -- in favor of a lowly civil servant.

In an interview yesterday, Swygert said he would like to stay and "fight the good fight" but that personal pressures make this the time to return to Philadelphia.

He said he hopes his successor -- three top lawyers, two with agencies and one with a Senate committee, are being considered -- will have "the guts to keep this an independent, aggressive, responsible body."

Swygert said federal workers must believe that the office of speical counsel and the MSPB are there to give them "a fair shake" or the president's whistle blower program will fall apart. Federal agencies must respect the judgment of the two operations, he said, so they will cooperate knowing they, too, will get a fair hearing.

Two of Swygert's staunchest defenders have been Office of Personnel Management director Alan K. Campbell and James McIntyre, who heads the president's Office of Management and Budget.

Campbell helped Swygert set up some field offices, and paved a few bureaucratic paths, although they have tangled on some issues. McIntyre, one of the Georgia inner circle, recently wrote cabinet members and their inspectors general telling them to give Swygert's office full cooperation in any investigation.

To show that he genuinely regrets Swygert's departure, Carter is expected to name him to a prestigious White House commission that will keep him in touch with Washington, and in the public eye.