Seated in a century-old mahogany chair in a church where Catholic heroes looked down from every wall, Pope John Paul II preached a traditional message yesterday to a gathering of diocesan priests at St. Matthew's Cathedral.

The mass, in which the pontiff urged the 1,500 priests to renew their devotion to the Virgin Mary, served as a sort of morning prayer session before the more temporal affairs of state in the afternoon -- visits with President Carter and foreign diplomats based here.

Outside the church, where a crowd of 12,000 people waited to see the pope, parka-clad men and woman waved papal pennants as vendors hawked assorted wares and woman and gay rights activists protested the pope's stands on the ordination of women and homosexuality.

Some had gathered there as early as midnight to get a good spot in the crowd. Patricia McQuitty of Silver Spring even spent the night in her car in front of the church, with her sister and brother.

The priests themselves began arriving around 8 a.m. from every part of the city, as well as from Richmond, Wheeling, W. Va., Baltimore and Wilmington, Del.

The pontiff's visit to St. Matthew's was billed as a major address to priests involved in parish or other pastoral work. But in contrast to hardline statements he made in other American cities on celibacy and the demands of the priesthood, the pope was more interested yesterday in reasserting the importance of Mary's role as "mother of the church" and "the best example of discipleship in Christ."

"Devotion to Mary waned, you might say, over the past 10 or 15 years," said the Rev. Americo DiNorcia of St. Martin's Church in Gaithersburg, commenting on the pope's homily. "There was a feeling that the emphasis on her was taking something away from Jesus Christ."

In the 1960s, many Catholics began questioning the doctrine of Mary's "immaculate conception" of the Christ child. And clergymen, in trying to keep in step with the times, de-emphasized theological concepts and instead stressed the gospel's social action themes.

But yesterday the pontiff, solemn and reflective exhorted the priests to look upon Mary as a model in our pilgrimage of faith.

"From Mary we learn to surrender to God's will in all things," he said in his strong, but familiar, Polish accent. "Learn from her to be always faithful, to trust that God's word to you will be fulfilled, and that nothing is impossible with God. Turn to Mary frequently in your prayer . . . ."

He chose as the setting for his address, St. Matthew's, the main church of the Washington archdiocese, and one of the oldest, most traditional and most beautiful, with its mixture of Romanesque and Byzantine architecture. The church, where President John F. Kennedy's funeral mass was said, has been visited by every American president since Theodore Roosevelt, and by numerous foreign dignitaries.

Set in downtown Washington amid stores, banks and office buildings, it attracts a mixture of elderly and young single persons living in the city. It also ministers to Catholic office workers who attend its daily noon mass.

Though the mass was closed to the public, the crowd outside heard it over a public address system. When it was over, and the pope took time for lunch at the cathedral's rectory, the crowd began chanting: "We want you, John Paul II."

Finally, at 1:25 p.m., the pontiff appeared on the rectory balcony, waving his white skullcap.

Smiling and pointing to the crowd, he called out, "John Paul II, he wants you. . . .And he will say to the President of the United States that he comes too late because of you.

Following is the text of Pope John Paul II'S homily for the Mass yesterday at St. Matthew's Cathedral:

Thank you very much, Cardinal Baum, for your welcome. Thanks to all the church of Washington, to the priests, religious brothers and sisters, to the laymen and laywomen, to all your community. My special greetings goes to Cardinal O'Boyle.

Dear brothers and sisters, Mary says to us today; "I am the servant of the Lord. Let it be done to me as you say."

And with those words, she expresses what was the fundamental attitude of her life; her faith.

Mary believed. She trusted in God's promises and was faithful to his will.

When the angel Gabriel announced that she was chosen to be the Mother of the Most High, she gave her "fiat" humbly and with full freedom: "Let it be done to me as you say."

Perhaps the best description of Mary and, at the same time the greatest tribute to her, was the greeting of her cousin Elizabeth: "Blessed is she who trusted that God's words to her would be fulfilled."

For it was that continual trust in the providence of God which most characterized her faith.

All her earthly life was a "pilgrimage of faith."