Democrats assailed the amendment as hate masquerading as religious tolerance. Republicans took turns donning a “Beetlejuice”-style jacket on the senate floor. And both sides were invited to a midnight cupcake party.

But after more than 39 hours, the longest filibuster in recent Missouri history over a religious liberty bill came to an end on Wednesday morning.

Missouri senate Republicans halted debate on a proposed constitutional amendment that would allow businesses and clergy members to refuse working with same-sex couples. Senate Republicans voted 23 to 9 to pass the resolution and put the question on the state ballot later this year.

The end came via a parliamentary maneuver that Democratic senator Maria Chappelle-Nadal, who spoke for a total of 13 hours, said went against normal senate traditions and was “an absolute disgrace”.

Chappelle-Nadal criticized Republicans for their refusal to negotiate, saying that many of them spent the filibuster sleeping in their offices or playing card games while Democrats debated the issues.

“They’ve done a serious injury to the Senate,” she said. “They are acting like house members.”

The amendment is similar to religious liberty proposals in several other states that give wedding vendors and other similar businesses the option to refuse service if they can cite religious opposition to same-sex marriage.

LGBT advocacy groups have condemned the proposed amendment, comparing it to similar legislation in Kentucky and Indiana.

Chappelle-Nadal called the amendment “filled with hate” and cloaked in a “smokescreen of religion”.

Missouri Republicans framed the resolution not as an assault against the LGBT community, but rather a measure of protection for those whose religious views would prevent them from working with same-sex married couples.

Given the large majorities held by Republicans in the Missouri legislature, senate Democrats felt compelled to filibuster in an attempt to derail the process.

The halls of the capitol building were full of unusual scenes on Tuesday night, with children of staffers resting on hallway floors, and one state senator practicing “cupcake diplomacy” by inviting everyone back to her office for late night treats regardless of politics.

The filibuster was by turns compelling and deeply monotonous, featuring passionate political stemwinders, oratorical flights of fancy, and repeated discussion about hot-button topics such as Ferguson.

To keep themselves amused, Republicans on the senate floor began taking turns donning a so-called “Beetlejuice” jacket – so named due to its uncanny resemblance to the striped garb worn by Michael Keaton in the 1988 film.

“My meds may be making me hallucinate,” said senator Gina Walsh, watching the scene unfold.

As the filibuster neared its thirtieth hour, senator Maria Chappelle-Nadal and senator Gina Walsh traded extended anecdotes about recent vacations on the senate floor. The gallery, by this time largely empty save for a few men in suits idly checking their smartphones, had no palpable reaction.

As was the pattern, lighter matters soon turned serious. Chappelle-Nadal delivered a wide-ranging speech touching on Syrian refugees, the legacy of American slavery, and people in her district suffering from debilitating illnesses from radioactive waste.

“And we’re sitting here talking about wedding cakes and floral arrangements,” senator Sam Sifton said.

“Pathetic, huh?” replied Chappelle-Nadal.

Speaking after the filibuster ended, senate president pro tem Ron Richard said the debate had simply run its course.

“We had 40 hours of long debate,” he said. “I thought it was fair and open. We gave everyone a chance to speak their mind.”

Richard said Republicans decided to call a halt to the proceedings after the ongoing debate became less substantive and began to meander.

Democratic senate minority leader Joe Keaveny has told reporters he is unwilling to rule out use of the filibuster in upcoming legislative battles – some of which are expected to be fairly contentious.

Democrats have the option to filibuster again when the resolution comes up once more for a final vote, and Chappelle-Nadal promised that Democrats would exercise that option again if Republicans choose not to end debate.

“I’m very proud of my colleagues,” she said, noting that while Democrats may have suffered a legislative reversal, they ultimately “made history”.