A presidential inauguration is by tradition the grandest ritual of America’s civil religion, but President Obama took the oath of office Jan. 21 in a ceremony that was explicit in joining theology to the nation’s destiny and setting out a biblical vision of equality that includes race, gender, class, and, most controversially, sexual orientation.

Obama’s speech, his second inaugural address, repeatedly cited civic and religious doctrines — namely the God-given equality extolled by the “founding creed” of the Declaration of Independence — to essentially reconsecrate the country to the common good and to the dignity of each person.

It was a faith-infused event that recognized both the original sins as well as the later atonements of America’s history, especially on race, which was front and center as the nation’s first African-American president took the oath on the holiday commemorating the Rev. Martin Luther King, Jr.

And Obama and other speakers vividly traced the nation’s tortuous path from slavery to civil rights — from the Emancipation Proclamation 150 years ago to the March on Washington 50 years ago, the latter presided over by King.

Yet Obama also declared that this tumultuous past was not an occasion for despair; rather, he said, it should inspire Americans to renew a joint pilgrimage that would never be finished but must always be carried forward as each generation adapts to new challenges, whether on the economy or identity.

“For our journey is not complete until our wives, our mothers, and daughters can earn a living equal to their efforts,” Obama told hundreds of thousands of cheering onlookers gathered on a chilly day on the Mall in front of the Capitol.

“Our journey is not complete until our gay brothers and sisters are treated like anyone else under the law,” he added, “for if we are truly created equal, then surely the love we commit to one another must be equal as well.”

The president also included immigrants and the working classes in his vision of a future American equality. But his inclusion of gay rights was especially pointed in that the first pastor he chose to deliver the day’s benediction — the Rev. Louie Giglio, a prominent evangelical — was forced to step aside earlier this month after anti-gay remarks he made in the 1990s surfaced.

Giglio was replaced by the Rev. Luis Leon, rector of St. John’s Episcopal Church across Lafayette Square from the White House.

The Episcopal Church as a denomination welcomes gay clergy and couples, and in his closing prayer on Monday, Leon asked that God allow Americans to see each other as a reflection of the divine image, “whether brown, black or white, male or female, first generation or immigrant American, or daughter of the American Revolution, gay or straight, rich or poor.”

Preceding Leon was another Latino, and a gay man, poet Richard Blanco, whose presence further underscored the shifts in public acceptance of gays and lesbians as well as the president’s increasing embrace of gay equality.

Americans, the president said, “have always understood that when times change, so must we; that fidelity to our founding principles requires new responses to new challenges; that preserving our individual freedoms ultimately requires collective action.”

That theme of renewed unity — spiritual and communal, crossing the many divides in U.S. society — was perhaps the central thread of this inauguration. It was a theme grounded in the national struggle for civil rights, a history that was everywhere present.

“As we sing the words of belief, ‘this is my country,’ let us act upon the meaning that everyone is included,” Myrlie Evers-Williams, the widow of civil rights leader Medgar Evers, who was killed by a white supremacist in 1963, said in her prayer to start the inauguration.

Evers-Williams, Obama and the other speakers framed that history in a way that evoked the nation’s past while setting out a new agenda for the future.

They refuted the bitter polarization that has gripped national politics by deploying the language and cadence of Scripture, of Christian anthems and national hymns, and not surprisingly a reference by the president to the most famous second inaugural address, that of Abraham Lincoln, one of Obama’s heroes.

“If you had any doubt that we are in the middle of a Fourth Great Awakening, you just missed one of the greatest inauguration speeches in American history,” Diana Butler Bass, a historian of American religion, wrote on Facebook as she watched the speech.

The religious language and symbols of the day could also be read as a direct rejoinder to the president’s die-hard opponents, many of whom insist that he is not a Christian and that he does not believe in America’s divine mantle.

Obama instead embraced American exceptionalism and repeatedly cited God’s will. The Brooklyn Tabernacle Choir sang “The Battle Hymn of the Republic” and icons of popular culture performed. “American Idol” star Kelly Clarkson sang “My Country,’Tis of Thee” and Beyonce the national anthem.

The other traditional elements of a presidential inauguration were also on display: Obama swore on historic Bibles used by King and Abraham Lincoln, and of course used the phrase “So help me God” at the conclusion of the oath of office, a later and unofficial addition.

The Obamas began the day in church on Monday — after attending services, as did Vice President Biden — on Sunday, and the religious ceremonies were to continue on Tuesday with a prayer service at Washington National Cathedral, led by Methodist preacher Adam Hamilton.

Yet the events were hardly a celebration of national or spiritual triumphalism. There was a profound awareness of the challenges overcome, yes, but also the obstacles — and internal divisions — to be faced if the country is to move forward.

In perhaps the most important, and little-noted, passage in his speech, Obama invoked the kind of Christian realism that was a hallmark of one of his favorite theologians, Reinhold Niebuhr. It is a theology that the president views as the kind of approach that should inspire leaders to reason together and act, however flawed the process or results may be.

“We cannot mistake absolutism for principle, or substitute spectacle for politics, or treat name-calling as reasoned debate,” Obama said toward the end of his address.

“We must act, knowing that our work will be imperfect. We must act, knowing that today’s victories will be only partial, and that it will be up to those who stand here in four years and 40 years and 400 years hence to advance the timeless spirit once conferred to us in a spare Philadelphia hall.”