NEW YORK — An annual Catholic fundraising dinner that included both major presidential candidates provided a night of laughter, as well as reminders of the Church’s battle to defend its religious freedom against the federal contraception mandate.

Al Smith, former New York governor and the namesake of the charity dinner, believed that government should aid those in need by “partnering with family, church, parish, neighborhood, organizations and community, never intruding or opposing,” said Cardinal Timothy Dolan of New York Oct. 18.

In the final weeks of what has become a very close presidential race, President Barack Obama and Republican presidential candidate Mitt Romney took a night off from campaign events to attend the 67th annual Alfred E. Smith Memorial Foundation Dinner at the Waldorf Astoria hotel in New York.

The event was held amid a tense struggle between the Catholic community and the Obama administration.

The Archdiocese of New York has joined with more than 100 other plaintiffs in filing lawsuits against the administration’s federal contraception mandate, which requires them to violate their faith by facilitating insurance coverage of contraception, sterilization and abortion-inducing drugs.

Cardinal Dolan’s invitation to Obama under these circumstances drew criticism from those who feared it may send the wrong message, allowing Obama to have a photo op with the president of the U.S. Conference of Catholic Bishops while downplaying the significance of the Church’s conflict with the administration.

While the attendance of presidential rivals is a long-standing tradition at the dinner, previous cardinals have failed to extend invitations to the contenders when Bill Clinton and John Kerry were running, reportedly due to their support for abortion.

The cardinal defended his decision in an Aug. 14 blog post, saying that his commitment to religious freedom had not waned, but that he saw the invitation as an opportunity for “engagement and dialogue.”

“In other words, it’s better to invite than to ignore, more effective to talk together than to yell from a distance, more productive to open a door than to shut one,” he said.

Laughter filled much of the evening. The candidates poked fun at themselves and each other on various topics, including the wealth that Romney amassed as a businessman and Obama’s poorly rated performance in the first presidential debate.

In a reference to his Mormon faith, which forbids the consumption of alcohol, Romney joked that his debate preparation includes refraining “from alcohol for 65 years before the debate.”

Touching on the subject of media bias, he said the next morning’s headlines describing the event would read: “Obama Embraced by Catholics. Romney Dines With Rich People.”

Romney also broached the subject of the contraception mandate in his remarks, saying, “Of course, the president has found a way to take the sting out of the Obamacare mandates for the Church. From now on, they’re going to be in Latin.”

On a serious note, Romney praised the work of the New York Archdiocese and the Al Smith Foundation.

“You answer with calm and willing hearts and service to the poor and care for the sick, in defense (of) the rights of conscience and in solidarity with the innocent child waiting to be born,” he said, adding that he is proud to be an “ally and friend” in these “great causes of compassion.”

Obama offered humorous jabs of his own, saying that he had earlier gone “shopping at some stores in Midtown,” while Romney “went shopping for some stores in Midtown.”

“As some of you may have noticed, I had a lot more energy in our second debate,” the president said. “I felt really well rested after the nice long nap I had in the first debate.”

Leaving humor behind, the president also applauded “the extraordinary work that is done by the Catholic Church.” He noted that “it’s written in Scripture that tribulation produces perseverance; and perseverance, character; and character, hope.”

Despite their differences, he said, “I’m certain that we share the hope that the next four years will reflect the same decency and the same willingness to come together for a higher purpose that are on display this evening.”

Cardinal Dolan closed out the night with remarks that began jokingly but then became reflective on the nature and importance of religious freedom.

He suggested that the annual dinner “shows the United States of America and the Catholic Church at their best,” uniting people of diverse faiths, economic backgrounds and political views in “an atmosphere of civility and humor.”

Despite their differences, he said, those gathered are grateful “to be people of faith and loyal Americans, loving a country which considers religious liberty our first and most cherished freedom, convinced that faith is not just limited to an hour of Sabbath worship, but affects everything we do and dare and dream.”

The cardinal concluded the evening by acknowledging “the ‘uns’ of the world,” including “the unemployed, the uninsured, the unwanted, the unwed mother, the innocent, fragile unborn baby in her womb, the undocumented, the unhoused, the unhealthy, the unfed, the undereducated.”

He recalled Al Smith’s conviction that government “should be on the side of these ‘uns’” by cooperating with private individuals and religious groups, “since, when all is said and done, it’s in God we trust — not, ultimately, in government or politics.”