Russia and Turkey vowed Tuesday not to let the assassination of a top Russian diplomat by an off-duty Turkish police officer derail their work or their fight against terrorism, as the countries prepared for a meeting in Moscow to discuss the war in Syria.

A team of 18 Russian investigators landed in Ankara to look into the killing of the envoy, Ambassador Andrey G. Karlov, whose body was to be returned to Russia on the same plane in which the investigators arrived.

In Moscow, the Russian foreign minister, Sergey Lavrov, and his Turkish counterpart, Mevlut Cavusoglu, placed flowers next to a portrait of Karlov, who was fatally shot Monday at a photography exhibition in Ankara, the Turkish capital. Lavrov said Russia was “grateful to our Turkish colleagues” for their condolences and for their rapid response to the killing.

“This tragedy is making all of us combat terrorism in a more resolute way and is making our meeting today ever more relevant,” Lavrov said.

The assassination of Karlov — which appeared to be the first killing of a top Russian diplomat since before World War II — elicited widespread worry that relations between Russia and Turkey might deteriorate. But most analysts played down those fears, saying the attack was unlikely to derail the rapprochement between the countries that has been underway over the past year.

Russian and Turkish officials said the killing would not derail cooperation by the two countries.

The Kremlin’s spokesman, Dmitry S. Peskov, said of the killing: “This is advantageous to those who wish to drive a wedge between Russia and Turkey, to hamper normalization of relations between Russia and Turkey — both in a bilateral sense and in terms of relations that allow to intensify and unite efforts on the way to political settlement in Syria.”

The attack is, however, an embarrassment for the government of President Recep Tayyip Erdogan of Turkey, and it has prompted questions about how the gunman, identified as 22-year-old Mevlut Mert Altintas, was able to enter the exhibition — “Across Russia, From Kaliningrad to Kamchatka, Through the Eyes of Travelers” — and gun down Karlov in front of a horrified crowd. The gunman was fatally shot by police officers.

The Turkish state-run Anadolu Agency reported that six people had been detained in the investigation, including the attacker’s mother, father and sister in the western city of Aydin and his roommate in Ankara.

A Russian deputy foreign minister, Oleg Syromolotov, told the Interfax news agency that Russian citizens should “think twice” before going to Turkey, where terrorist attacks occur “almost on a daily basis.” The United States closed normal operations at its embassy in Ankara on Tuesday, and at its consulates in Istanbul and Adana, after a person approached the embassy and discharged a firearm at 3:50 a.m., the embassy said. The person was taken into police custody, and no one was injured.

According to a preliminary forensic report, the gallery gunman fired 11 rounds, nine of which hit the ambassador, the Turkish newspaper Hurriyet reported. The gunman had checked into a hotel just behind the art center and planned the assassination there, Hurriyet said.

After the shooting, the gunman stood over the body of the ambassador and shouted, “Don’t forget Aleppo! Don’t forget Syria!”

According to the Dogan News Agency, the assailant’s uncle, also detained after the attack, used to be the principal in a network of schools that were shut down over alleged ties to the cleric Fethullah Gulen, who lives in exile in the United States and is a major opponent of Erdogan’s government. Gulen, through a representative, has denied any role in the assassination.

Murat Yetkin, in a column for Hurriyet, said the fact that the gunman was killed — rather than captured — would hinder the investigation. “If it was possible to capture him intact or wounded, but he was killed instead in a gunfight, this is like a sabotage,” Yetkin wrote.