Maryland Governor Martin O'Malley is inching closer to backing gay marriage.

The Democrat has previously said he supports recognizing gay and lesbian couples with civil unions.

But in March, O'Malley endorsed an opinion by Attorney General Douglas F. Gansler that allows the state to recognize the out-of-state marriages of gay couples.

And he went further on Thursday, implying that he would sign a gay marriage bill if approved by legislators, the Washington Post reported.

O'Malley made his remarks on DC-based WTOP's Ask The Governor radio show.

In response to a caller's question on the subject, O'Malley reiterated his support for civil unions, but then added that “should the legislature find a way to reach that compromise in another way, I would sign a bill like that … we need to find a way to support equal rights, and that is true when it comes to committed gay and lesbian couples and the unions in which they choose to enter and raise children and all the issues that go with that.”

As a result of Gansler's opinion, gay couples who marry in neighboring District of Columbia will have their unions recognized in Maryland, despite a law that bans such unions.

That shift in the law touched off a heated debate in the Legislature, where Republican lawmakers scurried to reverse the opinion. They introduced bills to ban gay marriage and ban the recognition of out-of-state gay marriages, and attempted to impeach the attorney general, none of which met with much success.

But attempts to legalize gay marriage have also fizzled.

O'Malley most likely will face former governor Robert L. Ehrlich, a Republican who does not support marriage equality, in the fall.