Pope John Paul II ended his three-day visit to the heart of ancient Byzantium today, sounding a note of urgency in the movement to reunite the Roman Catholic church and the churches of Eastern Orthodoxy after 900 years of division.

In a historic reopening of an ecumenical dialogue with the Orthodox patriarch, Dimitros I, the pope said the "evangelization of the world waits for unity." He said he hoped an amalgam could be achieved by the end of the century.

In a speech at the patriarchate in Istanbul before flying here for a visit to the ancient Greek city of Ephesus, the pontiff expressed impatience for full communion between the churches, saying, "We must rise above the habits of isolation."

"The question is not if we can restore full communion, but if we have the right to stay separate," the pope said. He indicated that a new joint theological commission would soon begin to study such thorny issues as papal infallability and attitudes toward divorce, which have kept the churches apart since the 11th century. Together Roman Catholicism and Eastern orthodoxy embrace an estimated billion people.

The pontiff said leaders of the churches should not be afraid to "reconsider" canon law that has stood firm for years while the churches remained divided.

"Is it not time to hasten the step toward the perfect fraternal reconciliation?" the pope asked. He said, "The plague (of disunity) is not yet healed, but the lord can heal."

For a millenium, the pope said, the "sister churches grew up side by side." and for another millenium were "darkened by distance." In the third millenium, he said, meaning the year 2000, the goal of unity could be attained. To illustrate his point on the day of the feast of St. Andrew the pope observed that Andrew was the brother of Peter, the first apostle, and that the spirit of brotherhood could be restored between the Vatican and the pariarchate of Constantinople. In contrast to homilies he delivered during his one-day visit to Istanbul, the pontiff restricted his remarks mostly to ecumenical affairs, leaving aside the appeals for collaboration between Moslems and Christians he made yesterday.

The pope flew to Izmir, in western Turkey on the Aegean Sea, and traveled by army helicopter to Ephesus, the site of the second ecumenical council which proclaimed in 431 the dogma of the divine motherhood of Mary. That decision led to a schism with Nestorianism, named for Patriarch Nestorius of Constantinople, which maintained that Jesus was born a man.

Dressed in his familiar white cassock and scarlet cape, the pope visited the shrine of the Holy Virgin, which religious tradition says is the place where Mary died after being taken to Ephesus by St. John. The stone house was named as Mary's house in a revelation in the 19th century by Sister Catherine Emmerich, a German invalid nun who never left Germany.

About 700 persons, most of them American servicemen from the Sixth Tactical Air Forces base near Izmir, cheered the pope, occasionally shouting "Viva il Papa."

The crowd also included about 100 Polish employes of a contracting firm building a power plant south of here. The poles erected a large sign welcoming the Polish pope. The pope delivered his homily in French, but at the end offered greetings in English, Polish and Italian.

An incident in the middle of mass caused brief alarm for the hundreds of security forces patrolling the area. As the pope started to take the communion wafer and the wine three gunshots in rapid succession rang out.

Soldiers and gendarmes ran toward the report, but authorities later said a guard stumbled and accidentally discharged his automatic weapon. The episode occured several hundred yards from the pope, who did not appear to notice.

Turkish authorities have been edgy throughout the visit because of assassination threats by rightist terrorists and Armenian nationalists. Last night, nine banks in Instanbul reportedly were bombed.