WASHINGTON — Barack Hussein Obama took the oath of office on Monday in front of hundreds of thousands of onlookers, publicly beginning his second term as president of the United States.

While the official swearing-in occurred in the Blue Room of the White House on Sunday, U.S. Supreme Court Chief Justice John Roberts administered a ceremonial oath of office to Obama on the steps of the U.S. Capitol Monday morning. The inaugural crowd, though smaller than the 1.8 million who came to watch Obama’s first inauguration in 2009, filled the National Mall with enthusiasm about the day’s proceedings and optimism about the coming four years.

Obama’s inaugural address, which lasted for nearly 19 minutes, stressed many of the themes central to his re-election campaign such as climate change, gay rights and America’s role in the modern world. At the same time, Obama referenced the Declaration of Independence and civil-rights history while expounding his vision of equality and progress in America.

“For we, the People, understand that our country cannot succeed when a shrinking few do very well and a growing many barely make it. We believe that America’s prosperity must rest upon the broad shoulders of a rising middle class,” Obama said.

While stating that the country will need to make “hard choices to reduce the cost of health care and the size of our deficit,” Obama argued that reforms must not unduly harm the old or the young.

“The commitments we make to each other — through Medicare and Medicaid and Social Security — these things do not sap our initiative; they strengthen us. They do not make us a nation of takers; they free us to take the risks that make this country great,” Obama said.

Obama framed the issues of equal pay, gay rights, voting rights and immigration in terms of equality. He also alluded to his support for gun-control legislation, mentioning Newtown, Conn. and adding that children from all over the nation must “know that they are cared for and cherished and always safe from harm.”

Many of those present on the National Mall considered Obama’s speech to be an assertive attempt to set his second-term policy agenda.

“I thought that he was aggressive in his speech — that he made it pretty clear where he stood and where he wanted to go,” said Althea McMillian, who flew to Washington from Mobile, Ala. to witness the inauguration. McMillian, an Obama supporter, said that she was pleased but unsurprised by the president’s tone. Compared to Obama’s inaugural address in 2009, “this one seems to be a little more forceful. … I think he said some of the same things, but after four years of experiencing things and knowing what he truly has to face, he was just a little more defined.”

Jeannette Garcia, an Obama supporter and high school senior from Florida, said that the president was more willing to broach controversial topics than he was during the campaign.

“I thought he pointed out a lot of things that people had been wary about during the campaigns, a lot of issues that he didn’t really address as well then,” Morrison said. She added that she was particularly pleased that Obama talked about gay rights and immigration reform.

Although most people in the crowd seemed to have supported Obama in the most recent election, enthusiasm for his re-election was far from universal. William Hollingsworth of Greenbelt, Md., said that although he voted for Obama in 2008, the president’s fiscal policies led him to switch his support to libertarian Gary Johnson in 2012. He said he is disappointed with both parties, but still thinks, “[Obama] is a good guy. I think he’s got a lot of good things to do for the nation, but I just don’t agree a whole lot with his fiscal policies.”

The atmosphere on the National Mall was festive Monday, and American flags seemed to be everywhere. According to the National Weather Service, the temperature reached a high of about 40 degrees — warmer than in 2009, when Washington experienced one of its coldest inauguration days in history with a noontime temperature of 28 degrees.

The ceremonies on Monday included a poem reading by Richard Blanco, prayers by Myrlie Evers Williams and the Rev. Luis Leon, and musical performances by artists and groups including Beyoncé and the United States Marine Band.

Correction: Jan. 23

A previous version of this article mistakenly stated that Rev. Louie Giglio delivered a prayer during the inaugural ceremonies. In fact, Rev. Luis Leon, an Episcopal priest, delivered the benediction.