Republicans and Democrats prayed for the president and one another at Thursday’s National Prayer Breakfast, where Rep. Janice Hahn (D-Calif.) laughingly suggested that her friendship with Louie Gohmert (R-Tex.) might prove the existence of God, because nothing else could explain it.

Gohmert, who co-chaired the annual event with Hahn, sallied that “it’s easy to pray with people who are wrong on the issues when you have a common heart.”

In its 62nd year, the breakfast is a D.C. institution, church and state joining hands for a couple of hours at the Washington Hilton, where President Ronald Reagan was shot and the White House Correspondents’ Dinner holds its “nerd prom” every spring.

Official Washington is expected to attend, and does; Vice President Biden and Secretary of State John F. Kerry were in the crowd of 3,200 this year, as was President Michel Martelly of Haiti and President Bujar Nishani of Albania. Every American president has done so since Eisenhower, in 1953, told those present, “You can’t explain free government in any other terms than religious.”

A non-believing president — or even one who prefers private demonstrations of faith — might not be entirely comfortable at the service, in which God is invoked and the politics of religion mostly go unmentioned.

In the beginning were the jokes: “I, by the way, have always found Louie to be unbelievably gracious,’’ President Obama said, adding, “I don’t watch TV, I’ve got to admit.’’

The crowd itself was on the saucy side; the man on my right in the overflow ballroom, where the morning’s speakers appeared up close and in high definition, volunteered that he was struck by how much the White House ages every POTUS and FLOTUS, while the man on my left exclaimed, “What did they do with her eyebrows?”

Even the scrambled eggs and paprika potatoes were roasted from the dais: After Gohmert broke Julia Child’s rule — never speak ill of the food you’re serving — Hahn reminded him that their guests had paid big bucks for it, and he sighed, “I wish it really was true that you get what you pay for.”

But unembarrassed prayers were offered, too, and as the first lady nodded encouragement, Bethany Hamilton, the author of “Soul Surfer,” spoke about how losing her arm in a shark attack had given her the chance to help kids with cancer.

The keynote speaker, USAID Administrator Rajiv Shah, urged those present to end extreme poverty in our lifetime, and he became emotional as he told the story of a woman forced by famine, rather than the Nazis, to make the kind of “Sophie’s Choice’’ described in William Styron’s novel.

At a Somali refugee camp, Shah said, he met a mother who’d been traveling with her two children, carrying them one at a time until it became clear that they would all die unless she put one down: “She looked down at her two children and said a prayer, then she made the excruciating decision to leave one of them behind so she could save the other.”

When the president’s turn came, he asked God to bless our men and women in uniform and “one colleague of mine who is missing today. A great friend of mine who I came into the Senate with, Senator Tom Coburn,’’ who has cancer. “Tom is going through some tough times right now, but I love him dearly, even though we’re from different parties. He’s a little closer to Louie’s political perspective than mine, but he is a good man, and I’m keeping him and his family in my prayers all the time. So just a shout-out to my good friend, Tom Coburn.”

Sometimes, when critics say that the president doesn’t speak openly about his faith, I feel guilty, because he does, and we just don’t quote him.“Each time we gather,’’ he said at the breakfast, “it’s a chance to set aside the rush of our daily lives; to pause with humility before an Almighty God; to seek his grace; and, mindful of our own imperfections, to remember the admonition from the Book of Romans, which is especially fitting for those of us in Washington: ‘Do not claim to be wiser than you are.’ ”

It was God, the president said, who “directed my path to Chicago and my work with churches who were intent on breaking the cycle of poverty in hard-hit communities there. And I’m grateful not only because I was broke and the church fed me, but because it led to everything else. It led me to embrace Jesus Christ as my Lord and Savior. It led me to Michelle, the love of my life, and it blessed us with two extraordinary daughters. It led me to public service. And the longer I serve, especially in moments of trial or doubt, the more thankful I am of God’s guiding hand.”

He spoke of the work done by faith-based groups and the inspiration he’s drawn from leaders of other faiths, adding that, “I am especially looking forward to returning to the Vatican next month to meet His Holiness, Pope Francis, whose message about caring for the ‘least of these’ is one that I hope all of us heed.’’

He ended with a defense of the religious liberty that some Catholics and other Christians feel that his contraception mandate effectively denies them, though he naturally said nothing about that.

As the faithful filed out of the ballroom, several people said that having the president pray with them meant something. “Most of the people here lean toward a conservative mind-set,’’ — himself included, said George Peart, who is in wastewater-treatment equipment sales in Madison, Miss. But, he said, Obama “professes a relationship to Christ, and I love his humanity.’’