Ms. Warren said the request for an exception “smacks of corruption, plain and simple.”

“The American people deserve to know that you are making decisions in our country’s best security interests, not your own financial interests,” Ms. Warren said. “If you can’t make those commitments to this committee, that means you should not be confirmed as secretary of defense.”

Bristling, Mr. Esper defended his ethics.

“I went to war for this country,” he responded. “I served overseas for this country. I stepped down from jobs that paid me well more — well more — than when I was working anywhere else. And each time, it was to serve the public good and to serve the young men and women of our armed services.”

Mr. Esper was confirmed as secretary of the Army in November 2017. He was tapped as the acting defense secretary last month, when Patrick M. Shanahan stepped down amid revelations about domestic abuse charges in his family.

The Pentagon has gone without a Senate-confirmed leader for seven months, after the resignation in December of Jim Mattis, Mr. Trump’s first defense secretary. Mr. Mattis, a retired Marine general, left the role in opposition to the administration’s stance on alliances and its decision to withdraw all American forces from Syria.

Mr. Shanahan was Mr. Mattis’s deputy, and had served as acting defense secretary from December until his own resignation in June.

Mr. Mattis’s legacy hung over much of Tuesday’s hearing, as lawmakers referred to that era in the Pentagon as a measuring stick for what they expected from Mr. Esper.

Senator Gary Peters, Democrat of Michigan, bluntly asked Mr. Esper if his approach to foreign policy hewed more closely with the president’s or with that of Mr. Mattis. Mr. Esper sidestepped the question.