Mr. Sanders is the first Democratic candidate to appear on a 2020 town hall event on Fox News, known for conservative prime time hosts and their forceful defenses of President Trump. The Democratic National Committee has said it will not hold any 2020 debates on Fox, citing troubling ties between the network and the president.

[Who’s running for president in 2020? Keep up with who’s in and who’s out with our candidate tracker.]

Mr. Sanders occasionally sparred with Mr. Baier and his co-host, Martha MacCallum, and at points was noticeably defensive, pushing back on questions. For instance, while he reiterated that wealthy people and corporations should pay more in taxes, “whether it’s me or you or anybody else,” he did not directly answer when asked whether he would personally be willing to pay a top marginal tax rate of 52 percent, as he proposed for high-income Americans during his 2016 campaign.

Instead, in a tone of frustration if not outright agitation, he tried to turn the question on the moderators, saying Mr. Baier and Ms. MacCallum surely made more than he did.

When the moderators noted that Mr. Sanders had benefited from the tax legislation that the Republican-controlled Congress passed in late 2017, he emphasized that he had voted against it.

Mr. Sanders, who is Jewish and lost many family members in the Holocaust, also defended Representative Ilhan Omar, who has come under fierce attack from President Trump for her comments about 9/11 and Israel. Mr. Sanders said that while she perhaps needed to improve her communication with Jewish Americans, he did not believe she was anti-Semitic.

“It is not anti-Semitic to be critical of a right-wing government in Israel,” he said to applause.