With the belief that he was "doing God's work," Mark David Chapman today switched his plea on charges of murdering John Lennon from not guilty by reason of insanity to guilty.

The plea, to a charge of second-degree murder, was entered against the advice of Chapman's attorney and was announced by Acting Justice Dennis Edwards in a crowded courtroom in State Supreme Court in Manhattan.

Lawyers for both sides said later that Edwards told Chapman he probably would be sentenced to no more than 20 years to life in prison. Sentencing was set for Aug. 24.

"Mr. Chapman has exercised his constitutional right to amend plea of not guilty and to plead guilty to the charge of murder in the second degree," Edwards said.

There was no comment or statement from the 26-year-old Chapman. Pale and pudgy, the former mental patient sat quietly beside his attorney, with two guards nearby. The court-appointed attorney, Jonathan Marks, visibly upset, asked for a re-examination of the defendant to "determine whether he is competent to do what he did today."

Marks said that in the past it had been possible to have a good working relationship with his client, but since early this month, when Chapman believes he was visited twice by God, communication had been impossible.

"It has not been possible to have a meaningful dialogue with Mr. Chapman because of his firm belief that he is doing God's work by pleading guilty," said Marks. "He has not been capable of receiving my advice or realizing that one course of action might be more beneficial than another."

The judge, however, accepted the plea, saying that "the ultimate decision is not that of attorney, but of the defendant."

Chapman, who has a history of mental illness, had worked at a series of jobs from YMCA counselor to security guard to printer, and reportedly had attempted suicide twice before his attack on Lennon. He had also, before traveling from his home in Honolulu to New York last December, apparently become obsessed with Lennon. He signed himself out as "John Lennon" on his last day on the job as a security guard.

A few days later he arrived in New York, hanging out with Lennon fans in front of the musician's New York apartment. The afternoon of Dec.8, he asked Lennon for an autograph and received it. Later that day, as Lennon was returning home, Chapman called his name. When Lennon turned, he dropped into a combat stance and shot him repeatedly. When police arrived, he was calmly reading a book, "Catcher in the Rye." "I just shot John Lennon," he said.

"Catcher in the Rye" is another obsession of Chapman's. Two months after the shooting, he sent a handwritten statement to The New York Times, urging that the book be read.

"It is my sincere belief that presenting this written statement will not only stimulate the reading of J.D. Salinger's 'Catcher in the Rye' but will also help many to understand what has happened," he wrote.

That obsession apparently remained with him for some time.

Defense attorney Marks, after the court session this morning, said his client at first had wanted to stand trial "only to promote the reading of the book. . . ."

Pressed to describe his client's emotional condition, he said that Chapman was "psychotic . . . but that does not mean that everything he does is psychotic. . . ."

"I don't know whether he's sane or not," Marks said.