President Obama paid a call on “The Daily Show” on Thursday, submitting himself to the ritual of acerbic host Jon Stewart’s mix of tough questions and mock serious quips in an effort to reach a wide audience of potential voters less than three weeks before the election.

Stewart made Obama laugh several times, but he also pressed Obama on why his administration appeared “confused” in its response to the terror attacks on American diplomatic personnel in Benghazi, Libya, on Sept. 11. The White House first said the attacks were in response to an anti-Muslim Internet video before later calling it a terrorist attack.

“We weren’t confused about the fact that four Americans had been killed,” Obama replied. “I wasn’t confused about the fact that we needed to ramp up diplomatic security around the world right after it happened. I wasn’t confused about the fact that we had to investigate exactly what happened so it gets fixed. And I wasn’t confused about the fact that we’re going to hunt down whoever did it.”

The president added that “every piece of information that we get, as we got it we laid it out to the American people. The picture eventually gets fully filled in.”

Republican nominee Mitt Romney has criticized the president’s handling of the incident, arguing that the White House had not been forthright and questioning why the administration had not provided more security for the Benghazi consulate.

Stewart suggested that the administration’s response had not been “optimal.”

“Here’s what I’ll say. When four Americans get killed, it’s not optimal. We’re going to fix it. All of it,” Obama said. “The government is a big operation and any given time something screws up. And you make sure that you find out what’s broken and you fix it. Whatever else I have done throughout the course of my presidency the one thing that I’ve been absolutely clear about is that America’s security comes first, and the American people need to know exactly how I make decisions when it comes to war, peace, security, and protecting Americans. And they will continue to get that over the next four years of my presidency.”

The taping of the show, which will air at 11 p.m. Thursday, was part of a whirlwind trip for Obama, who started the day with a campaign rally in New Hampshire before arriving in New York for the show, a private meeting with campaign donors and a speech at the annual Al Smith charity dinner sponsored by the New York Archdiocese.

Obama sat for two seven-minute segments with Stewart, playing along when the host gently ribbed him and his top aides.

“How many times a week does Biden show up in a wet bathing suit?” Stewart asked at one point, prompting the president to joke that he had issued a directive to stop the vice president from doing so.

“But I’ve got to say, he looks pretty good,” Obama said with a laugh.

But the conversation was mostly serious. In the discussion on national security, which took up most of the second segment, Stewart asked Obama about the difficulty of protecting civil liberties while ensuring national security.

The president reiterated his pledge to close the Guantanamo Bay facility in Cuba, a promise he failed to achieve in his first term, and he blamed Congress for not allowing it.

Of his track record in prosecuting terrorism, the president said: “We’ve gone after al-Qaeda and its leadership. It’s true that al-Qaeda is still active, at least sort of remnants of it are staging in other parts of North Africa and the Middle East. Sometimes you’ve got to make some tough calls, but you can do so in a way that’s consistent with international law and with American law.”

Stewart ended the segments with another joke, asking Obama to guess how many e-mails the president’s reelection campaign had sent him.

“It depends on whether you’ve maxed out” on donations, Obama answered with a chuckle.