WASHINGTON — Defense Secretary Leon E. Panetta is supporting a plan that would keep 3,000 to 4,000 American troops in Iraq after a deadline for their withdrawal at year’s end, but only to continue training security forces there, a senior military official said on Tuesday.

The recommendation would break a longstanding pledge by President Obama to withdraw all American forces from Iraq by the deadline. But it would still involve significantly fewer forces than proposals presented at the Pentagon in recent weeks by the senior American commander in Iraq, Gen. Lloyd J. Austin III, to keep as many as 14,000 to 18,000 troops there.

The proposal for a smaller force — if approved by the White House and the Iraqi government, which is not yet certain — reflected the shifting political realities in both countries.

It also reflected the tension between Mr. Obama’s promise to bring all American forces home and the widely held view among commanders that Iraq is not yet able to provide for its own security. And it reflected the mounting pressures to reduce the costs of fighting in Iraq and Afghanistan, both wars that have become increasingly unpopular as the 10th anniversary of the attacks of Sept. 11, 2001, approaches.