Iran offered written assurances to the Biden administration last month that it wasn’t seeking to kill Donald Trump , U.S. officials said, a secret exchange meant to cool tensions between Tehran and Washington—as the Republican prepares for his White House return.

The Iranian message, delivered on Oct. 14 and not previously reported, came in response to a private written American warning sent to Tehran in September. U.S. officials said it reflected the administration’s public message that it considered the threats against Trump a top-tier national security issue and that any attempt on his life would be treated as an act of war.

The Justice Department last week outlined allegations that Iranian agents plotted to assassinate Trump before he was re-elected as president , in what officials have described as ongoing attempts by Iran to target the once-and-future president.

Federal prosecutors in August charged a Pakistani man with ties to Iran with plotting to kill Trump, prompting officials to bolster his security while on the campaign trail.

Iran has long vowed revenge against Trump for his decision to order the January 2020 U.S. drone strike that killed Qassem Soleimani , leader of the Quds Force , the group responsible for Iran’s covert military operations abroad. U.S. officials say Iran has also sought to harm other Trump administration officials involved in the Soleimani operation and the broader maximum-pressure policy on Iran.

The Tehran message came after an Oct. 1 Iranian missile attack against Israel and before Israel retaliated with airstrikes against Iranian air-defense sites and missile-production facilities on Oct. 26. The Pentagon said it played no role in the Israeli attack, but the Biden administration had increased forces in the region ahead of the Israeli airstrikes.

Three officials involved in Iran policy in Trump’s first term—Secretary of State Mike Pompeo , Iran envoy Brian Hook and national security adviser John Bolton —still have Secret Service protection since leaving those roles due to threats on their lives from Tehran. The Biden administration increased Trump’s Secret Service protection in July after obtaining intelligence about the alleged Iranian assassination plot.

Iran has dismissed claims in recent days that it was trying to assassinate the former president. Foreign Minister Abbas Araghchi called the allegations a “third-rate comedy.”

U.S. officials say their September message to Iran echoed repeated previous warnings against harming Trump but was sent in light of the new information.

The Iranian reply, which wasn’t signed by a specific official, repeated Tehran’s accusation that Trump had committed a crime by ordering the killing of Soleimani, the officials said.

U.S. officials say they are confident Washington’s message reached Iran’s leadership. They didn’t say whether the messages were sent via Switzerland, which represents U.S. interests in Iran.

Neither U.S. officials nor the Trump team commented on whether Iran’s reply was conveyed to the president-elect.

The Iranian mission in New York declined to comment.

The Iranian assurances came at a critical time in the lead-up to the U.S. presidential election. In the final days of the campaign, Trump addressed his planned approach to Iran in a second term several times, sending a conciliatory message. He said that while Iran must not develop a nuclear weapon, he wasn’t seeking regime change in Tehran or conflict with Iran.

People close to Iranian officials say Tehran is seeking to avoid confrontation with the Trump administration. Some Trump officials have promised a return to the maximum pressure approach of the first term that caused a deep economic crisis in Iran.

“Iran can’t seriously float trial balloons for engagement while plotting to eliminate its would-be negotiating partners. It’s like reaching out with one hand to make a deal while holding a blade in the other,” said Ali Vaez , senior adviser in Washington at Crisis Group, a conflict resolution organization.

Iran is currently taking other steps to signal potential outreach to the West , a central plank of President Masoud Pezeshkian’s pledge to improve the country’s economy by winning the lifting of sanctions on Tehran. Iran is currently hosting U.N. atomic agency chief Rafael Grossi for a visit, which both sides say is aimed at improving cooperation with the agency, which is responsible for overseeing Tehran’s nuclear work.

Western officials have grown increasingly concerned in recent months that Iran could decide to move toward building a nuclear weapon, an issue likely to be among the top challenges facing the incoming Trump administration.

Since Trump pulled the U.S. out of the 2015 nuclear deal during his first term, Iran’s nuclear program has advanced swiftly, giving it enough nuclear material to fuel around four atomic bombs. U.S. officials have said it could field a nuclear weapon in several months.

After meeting Grossi in Tehran, Pezeshkian said Iran was ready to work with the U.N. atomic agency to remove any doubts about its nuclear work.

“We have not and we will not seek to produce nuclear weapons in any way,” he said.

Iran has been weakened through Israel’s recent attacks on pro-Iranian regional militias and military strikes against central Iranian facilities. But the regime is believed to have a sprawling network of agents around the world. It has faced allegations of being behind assassinations and attempted killings of Iranian exiles abroad and against Israeli and U.S. interests.

Richard Nephew, a former senior member on the Biden administration team that sought to revive the nuclear deal with Iran, said Tehran’s assurances won’t change how difficult it would be to revive meaningful talks between the Trump administration and Tehran.

Removing the assassination issue might help diplomacy between Washington and Tehran, “but no one should be kidding themselves on how hard a deal would be to achieve on even just the nuclear issue given where Iran’s program is and the history of the” nuclear deal, Nephew said.

Write to Laurence Norman at laurence.norman@wsj.com and Alexander Ward at alex.ward@wsj.com