EXCLUSIVE

A surprise lesbian wedding broke out at a Utah bar co-owned by "Modern Family" star Ty Burrell ... but the actor didn't just stand around and watch, Ty actually PARTICIPATED in the ceremony, TMZ has learned.

Ty (who plays Phil Dunphy on the show) was hangin' out at Bar X in Salt Lake City on Friday where a group of pro-gay marriage supporters were celebrating the striking down of an anti-same sex marriage law.

During the party, one lesbian couple decided they were so excited ... they were going to GET MARRIED RIGHT THERE IN THE BAR ... and asked Ty if he would sign the marriage certificate as an official witness.

Of course, Ty obliged ... and the women -- one of whom posed for a pic with Ty (see above) -- took the plunge right there in the bar.

The sad part ... Ty was NOT ALLOWED to buy the couple a celebratory drink (employees in the bar tell us it's illegal for bar staff to buy patrons a drink in Utah).