Inside, a pastor preached about John the Baptist and not giving up when things don't work out. He connected the message to Obama, saying people viewed the president as a savior but the nation's problems are not easily solved.
Obama's church visit got attention because it was rare. The last time the president attended Sunday services in Washington was in July. And the family outing came days after a campaign ad by Republican candidate Rick Perry asserted Obama has been waging "war on religion."
Religion is "not always the most important reason people vote, but it never completely goes away," said John Green, a political scientist at the University of Akron who studies the issue.
"I think Obama goes into his re-election period with an opportunity to re-emphasize his faith and the connections of his faith to his policies, partly because he hasn't done it very much," Green said.
But it also presents an opening for critics to question the devotion of a president who as a candidate in 2008 had to go out of his way to refute claims, spread on the Internet and in emails, that he was Muslim. Even now, many Americans seem unaware of Obama's religious background.
Obama, who the White House says is a "committed Christian" and prays daily, has followed a winding path.
His Kenyan-born father was brought up Muslim but was a "nonbeliever" according to Obama's telling. He said his mother was skeptical of religion, and when she moved them to Indonesia, he attended a Catholic school and a secular school where Muslims were the majority. While living in Hawaii with his grandparents, Obama went to a Unitarian Universalist church.
As a rising political figure, Obama spoke how he overcame his own reservations and was baptized after college. "I felt God's spirit beckoning me. I submitted myself to his will, and dedicated myself to discovering his truth," he wrote in his book, The Audacity of Hope.
Then came a roiling controversy that threatened to upend his presidential campaign: the publicity around sermons by his pastor, the Rev. Jeremiah Wright of Trinity United Church of Christ in Chicago.
Wright said U.S. leaders caused the 9/11 terrorist attacks by supporting terrorism abroad and claimed the government tried to wipe out African-Americans with drugs and AIDS. God bless America? Wright said it should be "God d-- America."
Obama severed ties with Wright and his campaign recovered. On Inauguration Day, he invited two noted pastors to pray: Rick Warren, the evangelical megachurch leader, and Joseph Lowery, a leader in the civil rights movement.
Since then, Obama's religious life has been little discussed - partly because the economy has dominated talk in Washington, and partly because Obama practices more privately.
Obama has been to church in Washington about nine times, according to a count by Mark Knoller, a CBS News White House correspondent who keeps statistics on presidents. Michelle Obama and her children are not known to attend services on their own, but the first lady has visited churches around the country as part of her effort to combat childhood obesity.
President George W. Bush attended church more frequently but, like Obama, did not join a church in Washington and preferred to worship at the more private Evergreen Chapel at Camp David, where the Obamas sometimes attend. Jimmy Carter continued to teach Sunday school while in the White House. Ronald Reagan took a lower key approach.
Presidential outings are always a heavy affair. Streets are cleared. Traffic is disrupted. Churchgoers must pass through security.
"He regrets causing such a distraction that other people can't worship," said the Rev. Joel Hunter of Northland church in Longwood near Orlando, who writes weekly devotionals for Obama.
But the lack of visibility has clouded public perception. A 2010 Pew Research Center poll found that 18 percent of adults think Obama is Muslim, up from 11 percent in 2009. Thirty-four percent correctly identified him as Christian while 43 percent said they did not know Obama's religion.
"That is the dilemma," Hunter said. "If you are more private in your personal development, then it creates a vacuum. People fill it in with the latest email," a reference to attacks preying on fears of Muslims.
The White House said Obama prays daily and has a circle of pastors, Hunter included, who provide spiritual advice. "The president's Christian faith is a part of who he is, but not a part of what the public or the media is focused on every day," read a statement.
Obama has invoked religion during ceremonies and faith-based events. He said he called an Easter prayer breakfast this spring because "as busy as we are, as many tasks as pile up, during this season, we are reminded that there's something about the resurrection - something about the resurrection of our savior, Jesus Christ, that puts everything else in perspective."
As the election approaches, religion will return as an issue. Mitt Romney, one of the top Republican candidates, faces potential problems in the primary because he is Mormon, which some other Christians view with suspicion. Newt Gingrich became a Catholic in 2009 but carries the baggage of two divorces and infidelity. Perry is trying to regain his footing in the race by playing up his faith.
"I'm not ashamed to admit that I'm a Christian," the Texas governor says in his new TV ad. "But you don't have to be in the pew every Sunday to know that there's something wrong in this country when gays can serve openly in the military, but our kids can't openly celebrate Christmas or pray in school. As president, I'll end Obama's war on religion, and I'll fight against liberal attacks on our religious heritage."
Perry was wrong about school prayer. Schools cannot hold Christmas events or prayers that focus on one religion, but children are allowed to pray and openly celebrate Christmas.
The Perry campaign says the "war" extends to Obama's decision not to defend the federal ban on gay marriage in court.
Religious conservatives have found reason to disagree with Obama over some policies, including the insurance mandate under the health care law, which some say violates the rights of those to forgo coverage because they think God is their protector. The law includes religious exemptions that critics say are vague.
At the same time, Obama has been praised for strengthening faith-based government outreach.
"When Michelle and I hear our faith questioned from time to time, we are reminded that ultimately what matters is not what other people say about us but whether we're being true to our conscience and true to our God," Obama said during the February National Prayer Breakfast. "Seek first his kingdom and his righteousness and all these things will be given to you as well."