More details have emerged about the gunman’s actions in the days leading up to the shooting.

The night before the attack, Lieutenant Alshamrani showed videos of mass shootings at a dinner party, according to a person who was briefed on the investigation.

Days earlier, he and three other Saudi military trainees were in New York City, visiting several museums and Rockefeller Center. There has been no indication that the trip was more than a sightseeing tour.

Still, several dozen F.B.I. agents and New York Police Department detectives have been working to learn everything they can about the visit, which lasted for about four days, according to a person with knowledge of the matter. The agents and detectives have been tracing their movements through credit cards, surveillance video and other means, the person said.

It was not clear whether the April classroom incident will play any role in the investigation.

According to the communication describing the encounter, Lieutenant Alshamrani was visibly upset and reported what happened to managers of CAE USA, which provides instruction to civil and military aviation students. (Delaware Resource Group is a subcontractor to CAE.) The American student who helped the lieutenant draft the complaint was one of two who accompanied him when he went to file it, according to the person who spoke with the Saudi trainee about the complaint.

The CAE managers offered to have the instructor apologize, but Lieutenant Alshamrani turned that offer down, and instead spoke to the naval office that oversees international students, the person said.

Several government employees thought that disciplinary action should be taken against Mr. Day, but he continued to instruct students, the person said. About a week after the incident in April, Lieutenant Alshamrani was paired with Mr. Day for simulated flight training, according to a schedule reviewed by The Times. He again complained to CAE managers, and the session was canceled and rescheduled with a different instructor, the person said.

As part of a terrorism investigation, federal authorities will also be attempting to determine whether there was a political or ideological motive behind the shooting.