Around the same time, Mr. Lahouaiej Bouhlel stabbed one of his children’s toys with a knife, and his wife became fearful for her children and sought a divorce, Deborah said.

He moved out, and occasionally gave her some money to support the children, but not much and not often, said Mrs. Lahouaiej Bouhlel’s lawyer, Mr. Garino.

In Nice, Mr. Lahouaiej Bouhlel appeared on the police radar for theft and violence, most recently in January, when he got into a fight with another motorist and threw a wooden pallet at him.

Mr. Lahouaiej Bouhlel received a six-month suspended sentence in March. By then, he may have already been fixated on carrying out violence on a grandiose scale, Mr. Molins, the Paris prosecutor, said.

But it was only in the two weeks before the Nice attack that Mr. Lahouaiej Bouhlel began to research rather mundane Islamic topics, including information about Eid al-Fitr, the celebration that ends the month of Ramadan, Mr. Molins said.

He searched the internet for information on the Orlando attack by Mr. Mateen, who had professed allegiance to the Islamic State. But Mr. Lahouaiej Bouhlel also searched for information on the recent killing of five police officers in Dallas.

Mr. Molins said Mr. Lahouaiej Bouhlel’s photographs on his cellphone, going back nearly a year, included ones showing crowds on the Promenade des Anglais. One set of images showed the crowd during the Bastille Day fireworks a year ago, another a crowd at a concert on the promenade, also last year.

Also included was an image of a January article from the local newspaper, Nice-Matin. It was about a man who purposely drove his car into a terrace cafe in the old port.