Army Spec. Ivan A. Lopez who killed three people and wounded 16 in a shooting rampage at Fort Hood was a father of four and had spent 10 years as a police officer in his native Puerto Rico before he joined the Army.

The mass shooting at the sprawling Army post in central Texas ended about four minutes after it began, authorities said, when Lopez, 34, was confronted by a military police officer. The officer opened fire, officials said, and Lopez killed himself with a shot to the head.

On Thursday even with the awful clarity of hindsight investigators and Lopez’s friends were struggling to identify the clues that everyone had missed.

Friends recalled Lopez as a father, a devoted son and a talented percussionist who had joined Puerto Rico’s police force in part because he wanted to play in the police department band. He had been crushed by his mother’s unexpected death last fall but afterward had returned to his Army career at a new base.

Army officials said Lopez, a truck driver who had served one short tour in Iraq, had been prescribed drugs meant to alleviate depression, anxiety and insomnia. They said he had received a full psychiatric evaluation just a month ago.

That review did not find “any sign of likely violence, either to himself or to others,” Army Secretary John M. McHugh told a Senate panel Thursday. “The plan forward was to just continue to monitor and treat him as deemed appropriate,” he added.

On Thursday, investigators said there were reports that Lopez had argued with another soldier before the shooting.

Still, one day into the investigation, Lopez seems different from the gunmen involved in two other shootings on military posts. Army Maj. Nidal M. Hasan, who killed 13 people at Fort Hood in 2009, had communicated with al-Qaeda leaders overseas. Aaron Alexis, the civilian contractor who killed 12 people at the Washington Navy Yard last year, was a loner with a history of bizarre outbursts.

Lopez had no apparent connections to terrorism, officials said. And at least on the surface he was not a man apart. He posted photos on Facebook of himself and his children at an amusement park. When he posted a picture of himself in uniform last year, 55 people “liked” it.

“Oh, my God. . . . I can’t believe it,” said Phanie Somar, a friend of Lopez and his wife from their time at Fort Bliss in El Paso. Until a reporter called Thursday, Somar did not know Lopez was involved in the Fort Hood attacks. “He’s very friendly, too. He’s sweet.”

Lopez was a native of Guayanilla, a city of 21,000 on Puerto Rico’s southwest coast. He came from a musical family: His father and brother played during Mass at the Catholic church they attended. Ivan Lopez followed the tradition. He spent nearly all of his life playing music and most of his adult life doing so in uniform.

“Ivan was quiet . . . introverted, calm,” said Edgardo Arlequin, Guayanilla’s mayor and the director of a youth band that Lopez joined when he was about 11. Arlequin said that in the many years he taught Lopez, he had not seen him show anger toward another student. “Never. Never. I never saw him get in a fight.”

Lopez joined the National Guard of Puerto Rico in 1999, when he was about 20. He played in the guard’s band, according to military records, and served a year on the Sinai Peninsula in Egypt, where U.S. troops serve in a multinational peacekeeping force that acts as a guarantor of a peace treaty between Egypt and Israel.

In 2000, he joined Puerto Rico’s police force and, eventually, its official band.

Lopez would have spent much of his time practicing and performing, said Officer Angel Miriani, a spokesman for the police force. But, he said, the members of the band are still police officers, and they can be called out to reinforce units on other parts of the island.

“The record is clean,” Miriani said Thursday, referring to Lopez’s disciplinary files.

In 2010, Lopez took a leave from the police force and entered the U.S. Army as an active-duty soldier. The force expected him to rejoin when his Army service ended.

When he entered the military, Lopez was a divorced father of two young children, both of whom remained in Puerto Rico. The rest of his immediate family including his mother, a sister and a brother were in Puerto Rico as well.

While stationed at Fort Bliss, Lopez met a woman named Karla a student at El Paso Community College. Somar, a friend from that time, said Lopez and Karla met at a nightclub.

The couple got married four months later, Somar said, in June 2010. That was soon after Karla found out she was pregnant.

Karla, originally from Durango, Mexico, dropped out of school and gave up her architecture studies to take care of their new baby, Angelique Marie, Somar said. Family members in Puerto Rico said Lopez now has another child in the United States.

Lopez then went through a series of moves, which friends said separated him from his family at times and left him stressed. In 2011, he spent five months in Iraq, serving as an infantryman. Military officials said there is no indication that he was injured in combat during that tour. He received a campaign medal for his service in Iraq.

After returning to Fort Bliss, Lopez was sent to Fort Leonard Wood, in Missouri, to train to be a truck driver. A military source said Thursday that Lopez was transferred from the infantry to truck driving because of a medical problem: He had plantar fasciitis, a painful foot ailment. Lopez seemed upbeat and grateful for the change.

In February, he was transferred to Fort Hood. At times when he was away, Karla and their baby called Angie Marie moved in temporarily with her parents outside El Paso.

In November, Lopez’s mother died unexpectedly in Puerto Rico. Glidden Lopez, a friend who is serving as a family spokesperson, said Lopez had remained close with his parents, calling them regularly.

After his mother died, Lopez returned to Puerto Rico for the funeral.

To friends, Lopez seemed deeply affected by his mother’s death, and he reportedly said the Army had granted him too little leave time.

By this year, Lopez was under a doctor’s care, having been prescribed medication. The drugs included Ambien, a sleep aid, the Army secretary said Thursday. Lopez also was being examined for post-traumatic stress disorder.

In March, he had the evaluation that determined he was not contemplating violence. That same month, his family moved in with him near Fort Hood.

On March 1, Lopez walked into a gun store near the base and bought the .45-caliber Smith & Wesson pistol he used in the rampage.