ANDERSON, Ind. (AP) _ A commando-style courtroom raid by mercenaries recruited through a Soldier of Fortune magazine ad was foiled after a state trooper infiltrated the group bent on freeing a convicted murderer, authorities say.

''Obviously, it would have been a disaster,'' state police Sgt. Tom Davidson said Tuesday, after the arrests of nine men accused of trying to free Indiana State Reformatory inmate Roger A. Jaske and the seizure of 10 handguns, four semi-automatic rifles, four shotguns, knives and ammunition.

''They have the firepower and manpower to carry it out,'' Davidson said. ''Obviously, the local deputies would have been outmanned and outgunned.''

Four of the men were arrested Sunday at the undercover officer's motel room, where the weapons were found and the men apparently were gathering for the assault on the Madison Circuit Court, police said.

''We had the state police special weapons team on standby and the Anderson police SWAT team, but when the decision was made to arrest the first four we had them away from their heavy artillery,'' Davidson said.

Four other men were arrested Monday as they arrived at the motel and a ninth, the alleged leader, was arrested early Tuesday in Anoka, Minn., police said.

Judge Fredrick Spencer disclosed the arrests Tuesday after jury selection in Jaske's involuntary manslaughter trial, saying the men, whom he described as mercenaries, had been recruited through Soldier of Fortune magazine ads.

The Boulder, Colo.-based magazine announced Monday it would no longer accept classified ads for mercenaries. Associate Editor James Pate said he could not explain the policy change and referred questions to publisher Robert K. Brown, who did not return telephone calls.

Jaske, 33, promised the men $10,000 plus expenses, and ''apparently had promised that after his escape he would lead them on other missions in which they would earn some big money,'' said police Lt. Mike Chambers.

The plan began to unravel about a year ago when authorities began to suspect that Jaske was trying to escape and was recruiting men to help him through the magazine ads, Davidson said.

Police said they found plans for the abduction of two court employees and specifying assignments for each of the men inside the courthouse.

''We believe that they would have killed people if the situation didn't work out the way they expected it to,'' said Davidson.

Everyone entering the court Tuesday was examined with a metal-detector and searched, and a plainclothes police officer stood inside with a shotgun.

Authorities don't know whether everyone involved in the plan has been captured, Davidson said. ''We don't think we're out of the woods yet until this trial is over and Jaske is back at the state reformatory.''

Jaske, of Michigan City, was sentenced in January 1977 to life in prison for first-degree murder. He is charged in the current case with in connection with the December 1983 death of inmate Clinton Page, 20, in a hazing incident. He also is charged with battery and with being a habitual offender.

Jaske is intelligent, resourceful and had planned escapes before, Davidson said. In another inmate's escape in September, Jaske apparently provided a modified AM-FM radio that could receive police frequencies, he said.

Police were unable to determine how Jaske first contacted Richard D. Alery, 28, of Anoka, identified as the leader of the gunmen, Davidson said.

He identified those arrested as Alery; Robert D. Crump, 23, of Abilene, Texas; Robert E. Underwood, 25, of Greenville, Texas; James M. Riggs, 27, of Enterprise, Ala.; Arthur E. Littler, 22, of Bailey, Colo.; Jody R. Jerome, 24, of Sandusky, Ohio; Paul A. Buffington, 19, of Cuyahoga Falls, Ohio; Mark A. Waite, 21, of Newburg, N.Y.; and Anthony S. Karen, 20, of Garden City, N.Y.

Karen is a U.S. Marine, Riggs is a civilian helicopter instructor at an Army base in Alabama and Alery is in the Army Reserve, Davidson said. He did not know their ranks.

All of the men were being held Tuesday night on preliminary conspiracy charges, Davidson said, and Alery was being held in the Anoka County Jail pending extradition to Indiana.