When Andrew L. Sonner stepped into the school lobby at one of a series of Montgomery County Democratic assemblies last June, he saw a sea of T-shirts emblazoned with his opponents name and lots of unfamiliar faces. Right then, recalled Sonner, "I knew I was in trouble at that convention."

Sonner, eight years in the post of Montgomery County state's attorney, was right and he was narrowly defeated for endorsement.

That has resulted in a bitter primary fight involving Sonner and a political newcomer, 30-year-old Daniel Cassidy, and the central issue is what some political opponents characterize as Sonner's hostile, arrogant personality and what he characterizes as his maverick streak.

"We have a very paranoid, almost sick party out here, hackled by undue rumor-mongering, back-biting and animosity, but this is the worst I've ever seen it," said one Democratic officeholder.

Rumors and allegations about Sonner, many unsubstantiated, run side by side with the concession, even from Sonner's most virulent opponents, that his office is administered well and staffed with "excellent young attorneys."

One political observer summed up the situation this way: "You can't have a two-term incumbent who has a good track record and is an attractive campaigner come this close to getting knocked off and not realize there is an awful lot of anti-Sonner feeling out there."

Cassidy has become the somewhat amazed beneficiary of that feeling. Cassidy is a staff member of the Montgomery County attorney's office, which handles the county's litigation.

He charges that Sonner has gotten himself far too involved in party politics for a man holding the powerful office of prosecutor, and pointed to what many call "the Jim Young thing" as a "glowing example" of that.

Jim Young was an applicant for the county sheriffs post in 1975, and lawyer Jay Bernstein, who served as chairman of a Democratic Central Committee panel screening applicants, remembers Sonner being "vehemently opposed to Young" the appointment did, in fact, go to Young.

Bernstein said that at a Saturday meeting of the panel, Sonner, who was pushing another candidate, told the group Young should not be appointed because he might be subject to prosecution involving a free membership he had accepted in a local country club.

That statement by Sonner, Benstein now charges, was "extremely improper because a prosecutor was involving himself in the political arena and utilizing his office for that purpose."

Sonner said his office was looking into free membership at the time and confirmed that he said Young was under investigation for possible violation of county conflict-of-interest statues." But he denied that he was an opponent of Young and asserted it's absolutely not true" that he was pushing anybody else for the job.

The prosecutor said the investigation already had been reported in the press, and that he believed it was his duty to mention it to the committee because it would have been a great embarrassment to the Democratic Party and to me if they appointed Jim Young knowing that there was a possible conflict of interest and then put me in the position of having to try that case."

At the end of the investigation neither Young nor other county officials were charged with any violations of the law.

Sonner asserted that his political opponents are dredging up stories like that to observe their real displeasure with him - his support for an "open" primary, jettisoning the traditional Montgomery County process of holding party endorsing conventions before primary day.

His critics, said Sonner are angered by his refusal to be a "get along-go along" type in the party. "I feel I have been more comfortable as a maverick," Sonner said.

Sidney Kramer, former County Council member and long politically active in the county, said anti-Sonner feelig boils down to the fact that when you speak your mind "you're going to make some people very happy and you're going to antagonize others." However, the "bottom line" should be how well Sonner runs his office, according to Kramer.

One leading Maryland lawyer, experienced in handling criminal matters, said Sonner is viewed as the "best state's attorney in Maryland" because he is considered honest and competent."

A local defense attorney said Sonner has put together "an excellent staff of bright young attorneys" and brought many sophisticated federally funded programs to his office.

On a recent campaign stop, Sonner pointed proudly to several of these programs, including one that assures proper treatment of victims and witnesses, and another that allows arbitration of neighborhood disputes that otherwise would clog District Court dockets.

He also is proud of the record of his major frauds unit, which investigates white collar crime. The unit, according to its chief, has brought charges in 73 cases since its inception in 1972 and has guilty pleas or convictions in all but three cases.

Cassidy, who worked for three years as a prosecutor of criminal cases in Prince George's County and tried about 100 jury trials, attacked Sonner for not personally trying more cases.

"It's trial office, and he should keep in contact with the pressures of the courtroom," said Cassidy.

Cassidy also was critical of Sonner's handling of perhaps the two most controversial investigations done by his office - a year-long probe of alleged bribery within the Washington Suburban Sanitary Commission and an investigation into alleged irregularities in the awarding of country contracts.

Cassidy charged that the investigations, fragments of which often leaked to the press, were long on newspaper headlines and short on results.

The contracts probe, launched by Sonner after allegations of irregularities by a demoted county official, never resulted in any indictments.

The WSSC investigation resulted in a flurry of indictments against several WSSC inspectors and local contractors, all of which were subsequently dismissed.

In both cases Sonner said "serious charges" were investigated thoroughly and responsibly" by his office and "we didn't guarantee any indictments." Sonner also denied that any of the leaks to the press came from his office.

Several Montgomery County lawyers and politicians commented that Cassidy is a "nice, bright kid with a good future," but even Sonner's opponents said they wonder if he has enough experience to tackle the county's top prosecutorial job - one that will carry a salary of nearly $50,000 a year in 1979.

In the next breath they come back to questions about the Sonner personality.

"A lot of people find him an intimidating man. He is totally unpredictable," said Del. Robert Jacques (D-Rockville), who makes no secret that he has been feuding with Sonner for years.

Says Sonner supporter Peter Messitte: "There are people who don't like Andy's style. He has never run with the pack."

Typically, Montgomery County Democrats cannot agree on just how tough a race the primary really is.

Several said that when Cassidy failed to win the support at a second county Democratic convention last June, he lost a crucial battle, and with it, the race.

But Sonner supporter Kramer says: "I think it's up for grabs. If I were Andy or his opponent, I'd get out and work my butt off."