Two days before Maryland Gov. Martin O’Malley (D) announced plans to sponsor a same-sex marriage bill, a Catholic archbishop strongly urged that he reconsider the move, suggesting the governor was acting out of “mere political expediency.”

Edwin F. O’Brien, the archbishop of Baltimore, said in a letter late last month that sponsoring the bill would “deeply conflict” with O’Malley’s Catholic faith and that he should resist pressure to do so after New York’s recent legalization of same-sex marriage.

New York Gov. Andrew M. Cuomo, another Democrat with a rising national profile, was widely credited with pushing a gay-marriage bill through a divided state legislature.

“Maryland is not New York,” O’Brien wrote. “We urge you not to allow your role as the leader of our state to be used in allowing the debate surrounding the definition of marriage to be determined by mere political expediency. The people of Maryland deserve no less.”

O’Malley responded to O’Brien on Thursday, citing a litany of issues on which he shares the church’s views. But, O’Malley wrote, “when shortcomings in our laws bring about a result that is unjust, I have a public obligation to try to change that injustice.”

Both letters were released Monday by O’Malley’s office in response to media requests. The exchange lends fresh insight into the pressures that public officials can face as they attempt to reconcile their religious faith with the policy positions that they advocate.

O’Brien’s letter also signals that the Catholic Church is gearing up for another fight on the issue in a state where the governor and both presiding officers of the legislature are Catholics.

O’Malley, who often attends weekday Masses and has sent his four children to Catholic schools, until recently advocated civil unions as an alternative to same-sex marriages.

During this year’s legislative session, he said he would sign a same-sex marriage bill if it reached his desk, but his advocacy for the measure was largely limited to private conversations.

After the legislation narrowly failed, supporters urged O’Malley to play a more visible role, and those calls grew louder after Cuomo signed New York’s bill.

At the July 22 news conference at which O’Malley announced his plans to sponsor a bill, he passed on several opportunities to explain how his personal thinking has evolved on the issue. Instead, he couched his support for same-sex marriage largely in legal terms, as he did in his response to O’Brien.

“I have concluded that discriminating against individuals based on their sexual orientation in the context of civil marital rights is unjust,” O’Malley wrote to the archbishop. “I have also concluded that treating the children of families headed by same-sex couples with lesser protections under the law than the children of families headed by heterosexual parents, is also unjust.”

O’Brien’s appeal to O’Malley was made in starkly personal terms.

“I am well aware that the recent events in New York have intensified pressure on you to lend your active support to legislation to redefine marriage,” O’Brien wrote. “As advocates for the truths we are compelled to uphold, we speak with equal intensity and urgency in opposition to your promoting a goal that so deeply conflicts with your faith, not to mention the best interests of our society.”

O’Brien continued: “It is especially hard to fathom your taking such a step, given the fact that our requests last year for you to sponsor legislation to repeal the death penalty and support students in Catholic and other nonpublic schools went unheeded.”

O’Brien was referring to legislation that would have created a tax credit for businesses that contribute to scholarships for private school students. O’Malley had supported the bill in the past, but he did not make it a priority this year, given the fiscal condition of the state.

During his first term as governor, O’Malley sponsored legislation to repeal the death penalty. The legislature balked, instead passing a bill in 2009 that raised evidentiary standards in capital cases.

O’Malley listed the repeal of the death penalty among the issues on which he and the Catholic Church agree. Others include: eradicating poverty, respecting the right of workers to organize, reducing infant mortality and having a fair and progressive income tax.

“I do not presume, nor would I ever presume as governor, to question or infringe upon your freedom to define, to preach about and to administer the sacraments of the Roman Catholic Church,” O’Malley wrote. “But on the public issue of granting equal civil marital rights to same-sex couples, you and I disagree. . . . I look forward to working with you on other issues of mutual agreement. And I respect your freedom to disagree with me as a citizen and as a religious leader without questioning your motives.”