A Montreal man charged with stabbing a police officer in the neck at a Michigan airport on Wednesday tried to buy a gun before the attack but was denied, the authorities said on Thursday.

The man, Amor M. Ftouhi, entered the United States from Canada last Friday, crossing over in his car into upstate New York, and making his way to Michigan on Sunday. While in Michigan, Mr. Ftouhi tried to buy a gun, the F.B.I. said, but it is illegal for nonresidents to buy and take possession of a gun in the United States.

After that purchase failed, Mr. Ftouhi decided to attack with a knife, which he bought in the United States, the authorities said. The additional details about the planning that went into the attack emerged on Thursday as a hazy portrait formed of Mr. Ftouhi, a 50-year-old married father of three who had worked as a truck driver in Canada.

Mr. Ftouhi, who was born in Tunisia and is a Tunisian and Canadian citizen, has lived in Canada for 10 years, according to an audio recording from his appearance in United States District Court on Wednesday. Mr. Ftouhi’s mother, three of his sisters and two brothers are in Tunisia and another sister lives in Switzerland.