Iran’s supreme leader, Ayatollah Ali Khamenei, performed funeral prayers on Wednesday for the country’s president who was killed in a helicopter crash, as thousands of Iranians packed the streets of Tehran on an official day of mourning.

The president, Ebrahim Raisi, 63, was killed along with Iran’s foreign minister, Hossein Amir Abdollahian, 60, and five others traveling with them on Sunday. Funeral observances began on Tuesday with a procession in Tabriz, the closest big city to the crash site in northwestern Iran. The bodies of Mr. Raisi and of the others killed were then taken to the holy city of Qom and to Tehran, the capital, ahead of Wednesday’s events.

Iran’s security forces implemented tight restrictions on vehicle movement and parkingin the area where funeral processions would begin, the Tehran police chief, Col. Abdolfazl Mousavipour, told state television overnight. State television also reported that public transportation would be free on Wednesday — declared a national holiday — to enable people to attend the funeral.

On Wednesday morning, state news media broadcast footage of huge crowds making their way to the University of Tehran, where the flag-draped coffins were housed in a large hall.

Ayatollah Khamenei, 85, entered with an entourage, laying down his cane in front of the coffins before performing the prayers. His words were carried on loudspeakers to crowds standing outside who bowed their heads in prayer, state media footage showed.

Mr. Raisi had been considered a potential candidate to succeed the supreme leader, who is in declining health. After performing the prayers, Ayatollah Khamenei embraced one of Mr. Raisi’s children, video on state news media showed, stroking the boy’s head.