Pope John II, still recuperating from an assassination attempt last May, today underwent an operation that doctors predicted would restore the full use of his damaged intestines.

The 61-year-old pontiff, whose recovery had been complicated by a viral infection in June, ws operated on of almost a hour this morning at Rome's Gemelli Hospital by the same doctors who treated him immediately after he was shot by a Turkish terrorist at St. Peter's Square May 13.

While a medical bulletin signed by the nine-man team said the operation "succeeded prefectly" and the pope's condition was "good," public optimism for a full recovery is tempered in private by some of the pope's own doctors. They say that although the pontiff may now be clinically cured, only time will tell whether he will regain the dynamism that has characterized his papacy since his election Oct. 16, 1978.

The pope's doctors indicate that he will stay in the hospital for a week to 10 days, then leave for a long, supervised convalescence at the papal summer residence at Castelgandolfo in the Alban hills above Rome. He is expected to remain thre at least two months, trying to regain his strength and the nearly 20 pounds he has lost.

He is also known to be contemplating using his time at Castelgandolfo on social and family life. He can be expected to delegate the church's day-to-day business to Cardinal Agostino Casaroli, the Vatican secretary of state who acts as something of a premier overseeing the church government.

Medical reserve on the pope's future is based on the severity of the pope's wound and possible after-effects from his infection in June, probably contracted from the 10 pints of blood he was given during the emergency operation.

Doctors close to the pope's medical team said that even though the pope is physically strong and was usually fit at the time of the shooting, revovery at age 61 is slower and harder than for younger men and often is not total.

These doctors quietly underline the point by referring to the pope's initial insistence on leaving the hospital and returning to the Vatican June 3, only three weeks after his shooting. Doctors advised that he was rushing things, but ever eager to return to his labor, John Paul II ignored their advice and rushed back to deliver prayers from the balcony of his apartment overlooking St. Peter's

In less than a week he was beset by persistent fever, later diagnosed as a cytomegalovirus infection of the blood, which can cause pulmonary and liver disorders. On June 20 the pope was forced to return to his 10th-floor room at the hospital until tests last week established that he was cured of the viral infection and thus able to undergo today's surgery.

The surgery was necessary to close the emergency colostomy prformed immediately after the pope was shot in the abdomen, severely damaging his intestines in several places.

The colostomy had provided the pope with an artificial tube to allow wastes to be voided without passing through his healing intestines. Today's operation reattached the colon to allow normal bowel activities to resume through the now healed intestines.

Dr. Emilio Tresalti, the medical director of Gemelli Hospital, declared after the operation today that "now we will have the same pope we had before."

Although the pope is understood to have promised his doctors that he will take it easy this time and follow their advice, few believe he will spend his time simply walking in the papal gardens and basking in the mountain air.

This pope, more than any of his modern predecessors, has always seen his role as that of a pastor, above all, to the citizens of Rome, to Italy and to the universal church. He can be expected to continue to pen the prayers and messages that even from his hospital bed he has recorded for Sunday broadcasts.

Prelates in the papal entourage insist that as soon as he is able he intends to resume his ministry as if nothing had happened, preaching in local churches, mixing among the throngs of worshipers who flock to St. Peter's to see him and traveling abroad to spread the gospel.

John Paul II's travels, more than anything else, have characterized his papacy and will be used as a significant gauge of his recovery.