MILWAUKEE (AP) _ A former judge accused of first-degree murder in the stabbing death of a lawyer will testify in his defense, a defense attorney said today in the trial's opening statements.

Former Lafayette County Circuit Judge Daniel P. McDonald, 43, is accused in the June 22 death of James C. Klein, 31, of rural Cuba City. Klein shared office space in Darlington with William D. Johnston, an attorney who defeated McDonald in an April election.

''Dan McDonald will testify he was at the law office and he's going to explain to you exactly what happened,'' attorney William Hayes said.

''The evidence will show that Dan McDonald had no intention whatsoever of killing James Klein,'' Hayes said. ''The evidence will show that he knew James Klein and he liked James Klein.''

Assistant State Attorney General Steven C. Ebert, acting as a special prosecutor for Lafayette County, said the state would present evidence that McDonald stalked Johnston ''morning, noon and night'' after losing the election and was seen several times near the law office on the morning of the killing.

''The results of this election shattered him. He didn't even come to work for two days,'' Ebert said.

Ebert said Johnston would testify that he observed the slaying through the locked glass door of his office.

''He saw James Klein backing away. He saw James Klein covered in blood. He saw James Klein reaching behind him for a door knob. He saw that his hand was covered with blood and he saw the defendent walking toward James Klein. He saw the defendent with a glove on his hand and with a knife and the knife was bloody,'' Ebert said.

''But for the misfortune of going to work and getting in the defendent's way, James Klein would be alive today,'' Ebert said.

Milwaukee County Circuit Judge Ralph Adam Fine on Tuesday ordered the jury sequestered during the trial.

McDonald, who is being held in Milwaukee County Jail, had pleaded innocent and innocent by reason of mental disease or defect.

Fine also agreed to sequester witnesses, but rejected a motion from prosecutors that Patrick McDonald, the accused's brother, be sequestered as a potential witness.

Patrick McDonald, an attorney, has been sitting beside his brother at the defense table.