Hundreds of thousands gathered in Tehran as Iran’s political and military leadership attended funeral prayers for Ali Khamenei, while his successor Mojtaba Khamenei remained outside public view amid continuing security threats and fragile United States talks.