Both Mr. Shanahan and Ellen Lord, the Pentagon’s top acquisitions official, said that if Turkey dropped plans to buy Russia’s S-400 antiaircraft system, the United States would welcome it back into the F-35 program.

The Russian system is an advanced surface-to-air missile system that can shoot down planes like the F-35. The United States wants Ankara to buy the American-made Patriot radar system, manufactured by Raytheon.

It has been difficult to determine if the United States and Turkey are serious about removing Ankara from the F-35 weapons program, or if each side is haggling for the best deal it can get on the Patriot. President Recep Tayyip Erdogan of Turkey has so far been insistent that his country is going ahead with its planned purchase of the Russian system. On Tuesday, he said that the United States had not given Turkey “an offer as good as the S-400s.”

The United States insists that the Russian system is incompatible with the F-35. American officials say that proximity between the S-400 and the F-35 could compromise the American program’s security.

“While we seek to maintain our valued relationship, Turkey will not receive the F-35 if Turkey takes delivery of the S-400,” Mr. Shanahan said in his letter. “In addition to threatening the security of platforms like the F-35, Turkey’s procurement of the S-400 will hinder your nation’s ability to enhance or maintain cooperation with the United States and within NATO, lead to Turkish strategic and economic over-dependence on Russia, and undermine Turkey’s very capable defense industry and ambitious economic development goals.”