President Obama was clearly annoyed by the tone of a reporter's question when he asked if the president was "content" with the Iran nuclear deal that left four Americans languishing in Iranian jails.

Obama called the question "nonsense."

The reporter who rankled Obama was Major Garrett, the chief White House correspondent for CBS News.

"As you well know, there are four Americans in Iran, three held on trumped-up charges, according to your administration, one whereabouts unknown," Garrett began his question. "Can you tell the country, sir, why you are content with all the fanfare around this deal to leave the conscience of this nation, the strength of this nation unaccounted for in relation to these four Americans?"

One of those Americans is Washington Post reporter Jason Rezaian who is in the midst of a secret trial in Iran.

Related: Trial of US reporter Jason Rezaian resumes in Iran

Garrett, a longtime White House reporter whose career has included stops at CNN, Fox News and National Journal, squeezed in one more question.

"And last week, the chairman of the Joint Chiefs of Staff said under no circumstances should there be any relief for Iran in terms of ballistic missiles or conventional weapons," Garrett continued. "It is perceived that that was a last-minute capitulation in these negotiations. Many in the Pentagon feel you've left the chairman of the Joint Chiefs of Staff hung out to dry. Would you comment?"

Obama smiled sarcastically as Garrett spoke.

"I've got to give you credit, Major, for how you craft those questions," Obama said, before admonishing the reporter.

"The notion that I'm content as I celebrate with American citizens languishing in Iranian jails, Major, that's nonsense, and you should know better," the president said.

Obama noted that he has met with families of some of the Americans held in Iranian custody, and that his administration is "working diligently to try to get them out."

Obama added that tying the release of the Americans to the nuke deal would have encouraged the Iranians to seek additional concessions.

Garrett stood by his question during an appearance online after the press conference and said that Obama had created a straw man in his response.

"My question did not suggest that he was content with the captivity of those four Americans," Garrett said. "My question was about the contentment, or the satisfaction, or the realization that it was necessary within the context of this deal to leave them unaccounted for. That was the essence of the question."

"Clearly it struck a nerve," he added. "That was my intention."

The other Americans besides Rezaian who Garrett referred to are Saeed Abedini, Amir Hekmati and Robert Levinson.

The interaction immediately lit up Twitter, where Garrett's name was trending by the time the press conference ended.

Many journalists celebrated Garrett's question, while others condemned the reporter and praised Obama's sharp response.

"There is an art to asking tight questions at a press conference where you may not get a follow up," tweeted veteran political reporter Jon Ralston. "Nobody does it better than [Garrett]."

Oliver Willis, a research fellow at the liberal Media Matters for America, was less impressed, joking that Garrett "still has a lil fox news in him, i see."