James G. Adams, the No. 2 man in the Federal Bureau of Investigation, unexpectedly announced his retirement yesterday.

The 28-year bureau veteran, last of the Hoover-era holdovers in a position of power at the FBI, announced he is leaving to return to his home state of Texas and take a position as head of criminal justice planning on the staff of Gov. William Clements.

The retirement was a surprise to most at the FBI and the Justice Department because the 52-year-old Adams has been associate director only a year and is nearly three years away from mandatory retirement.

The announcement also comes as FBI Director William H. Webster considers the results of an internal investigation in which Adams' name has been mentioned.

Webster made it clear yesterday, however, that Adams' sudden retirement was voluntary and not connected to the investigation of a possible FBI cover-up of allegedly illegal break-ins during domestic security investigations in the early 1970s.

Attorney General Griffin B. Bell requested the inquiry a year ago to determine why the FBI gave the congressional General Accounting Office and the Intelligence committees incorrect information about the number of break-ins. Adams testified under oath on the subject several times, but told The Washington Post last year that he did not know the information was wrong.

Because of Adams' potential liability, Webster's decision to elevate him to the No. 2 post a year ago was considered one of the new director's few controversial moves.

Yesterday Webster issued strong statement praising Adams and clearing him of any involvement in the alleged cover-up.

The investigation "has produced no evidence that [Adams] participated in, condoned or had knowledge of any such activities," Webster said.

The director also said: "Jim Adams has had a long and honorable career and I shall miss his wise and candid counsel . . . "

Adams said in a phone interview that he is leaving because he has an opportunity to return to Texas in responsible law enforcement job.

"You know I have a deep, abiding love for Texas and have always planned to return there," he said. "There is no other reason for my leaving."

He said he agreed with Webster about basic directions and policies in the bureau.

And he emphasized that he was not running away from the cover-up investigation. He said that had he not been cleared, "I would never have left until all those issues had been resolved."

Adams said he will leave the FBI in about a month and begin his new job as excutive director of Clements criminal justice division June 1.

Though he is leaving a $50,000-a-year job for one paying $39,000, he said, his $30,000 FBI pension will more than offset the loss in base pay.

Adams' ties to Texas are evident in his office. They include a cactus garden, a picture of the Alamo and numerous mementoes of the Baylor University football team.

Adams was reared in Texas, was a Japanese translator in World War II and then received B.A. and law degrees from Baylor. He served in the Texas state legislature two years before becoming an FBI agent in 1951.

Adams' rise in the FBI hierarchy was through the powerful administrative division under John P. Mohr, a close aide to J. Edgar Hoover. He also served-and made enemies, according to FBI officials-as an inspection division supervisor and a personnel officer in charge of promotions and transfers.

He became an assistant director in 1974, then chief of investigations and last year associate director. After Hoover's death in 1972, he became known increasingly as one of the FBI's most competent and knowledgeable officials.

During the tenure of Director Clarence Kelley and Webster's first year, he played a key role in briefing and testifying before congressional leaders. "He was the backbone on the bureau in those days," one high-ranking bureau field agent said yesterday.

It was during these same years of revelation about alleged FBI wrongdoing that Adams also was criticized by some colleagues.

When he was promoted to associate director, Time magazine ran a story about Adams filled with invective from veteran field agents. And just Monday night, J. Wesley Swearing, a former agent, told a national television interviewer that Adams was "incompetent" and a "liar" about the extent of FBI break-ins.

Adams said yesterday that he has learned to live with criticism. But one official familiar with his career said yesterday: "I think he just got fed up with the harassment." CAPTION: Picture, James B. Adams, a 28-year bureau veteran who is last of Hoover-era holdovers in position of power. By James K. W. Atherton-The Washington Post