During the last two months, Mayor Marion Barry has spent most Sundays in church--speaking at men's day programs, giving out special awards, standing to be recognized with his wife and son, mingling with church members in the fellowship hours after service.

He also met individually with ministers, stressing the blessings that his administration could bestow upon their congregations--day-care centers, housing grants, programs for senior citizens.

He appointed ministers to important city boards and commissions, issued special proclamations noting important church events, and a few weeks ago, his Ward 4 campaign organization sponsored a gospel extravaganza.

Wednesday, Barry's church-going produced its first payoff when 118 ministers--including the leaders of some of the largest, most prominent and most politically active congregations--endorsed his reelection campaign.

For Barry, the endorsement was a multiple political victory.

Washington's ministers--especially the Baptists, Pentecostals and some Methodist groups--have traditionally been a power base in the city, shepherds tending their flocks with a variety of social service programs dispensed in the fashion of ward heelers and precinct captains in cities with more developed political systems.

In political campaigns their support is courted, sometimes because an endorsement can be an entree to speaking before a congregation of dependable voters, sometimes because parishioners--especially undecideds--may follow the minister's lead in the voting booth, sometimes because of the value of a moral stamp of approval in a city of older, working-class black voters.

Barry's capture of the endorsements announced Wednesday appears to have set back the campaign of council member John Ray, who had been working to build a base among ministers for his candidacy, and lawyer Patricia Roberts Harris, who was hoping to pick up much of the churchgoing, backbone middle-class support that eluded Barry in the 1978 primary.

The endorsements could be especially helpful in Wards 4, 5 and 7 on the northern and eastern edges of the city. All are heavily populated by politically moderate, churchgoing, regularly voting blacks whom many consider a crucial force in city elections. Barry lost all three in 1978, but appears to be a favorite in them now.

The endorsements also were a victory for the political power of incumbency. In using his standing as mayor to win over church leaders, Barry reversed the earlier scenario of politicians anxiously waiting in the wings for ministers to endorse them.

In the 1978 Democratic primary, which long-shot Barry won with a narrow plurality of the vote, Barry strategists all but wrote off support from the churches.

"Marion wasn't getting too much from the churches last time," retail executive Joseph B. Carter, who worked as Barry's church coordinator in the 1978 election and now is doing the same work for Ray, said yesterday.

Ray, whose campaign for mayor has slowed in the last few months and who has run a distant third or fourth in most polls, said yesterday that he does not feel his campaign has been irreparably damaged by the church support of Barry. Ray said he questioned the value of the endorsements.

"You can't, no matter who you are, sell a bad product," Ray said yesterday. "The problem with ministers selling Marion Barry is that so many of them have had negative things to say about him in the past. It creates a dilemma for the congregation about what they are hearing and many of them are already cynical about churches and politics."

Harris' campaign director, Sharon Pratt Dixon, said the victory for Barry in the endorsements is largely in the perception that voters may get as the Sept. 14 primary approaches.

"There is the perception of momentum but I suspect these endorsements are empty expressions of support," Dixon said. "It's inevitable that some support will go to the incumbent. People are reluctant to offend a sitting mayor. But it's not sure that their support will translate into votes on election day."

"Pat is going to have to use a nonincumbent's strategy to combat this, just like Marion did in 1978 by building coalitions of outside groups that don't feel they are being heard in city hall."