Get breaking news alerts and special reports. The news and stories that matter, delivered weekday mornings.

Four people were dead, including the gunman, and at least 16 others were wounded in a shooting at Fort Hood, Texas, military officials told NBC News.

The gunman, identified as Ivan Lopez, 34 — an enlisted soldier — took his own life with a .45-caliber Smith and Wesson semi-automatic pistol, officials said.

A U.S. military official told NBC News that Lopez was an active-duty soldier who was assigned to a Sustainment Brigade.

All of the wounded and killed were also military, according to Lt. General Mark Milley, who spoke to reporters at the base after the shooting.

Milley, who didn't use Lopez's name pending family notification, said that the gunman was being evaluated for post traumatic stress disorder, and had self reported a traumatic brain injury.

The soldier had not been wounded in Iraq, but was being treated for behavioral problems, anxiety and "a number of other psychological issues," according to Milley.

The soldier "put his hands up and then reached under his jacket" when a female officer drew her weapon, Milley said. "He pulled out the gun, and she engaged, and he put the weapon to his head."

“Experience has taught us many things here at Fort Hood. We know the community is strong .... The soldiers who have served so bravely through the last 13 years in Iraq are strong, and we will get through this.”

Milley said that the shootings didn't appear to be related to terrorism or radicalism but that nothing had been ruled out so early in the investigation.

The soldier's body was found in a parking lot near the First Medical Brigade area, Milley said. His weapon had been bought in the area recently and wasn't registered with the base.

Three other people died in local hospitals, Milley said.

Doctors at Scott & White Memorial Hospital said they were treating eight patients — seven men and one woman. Three of the patients were said to be in critical condition and on ventilators, while five others were in serious condition.

Dr. Harry Papaconstantinou told reporters the victims' injuries included gunshots to their extremities, abdomens, chests and necks.

Let our news meet your inbox. The news and stories that matters, delivered weekday mornings. This site is protected by recaptcha

Others were being treated at Carl R. Darnall Army Medical Center on base.

"This was another sad day for central Texas," said Dr. Glen Couchman, the hospital's chief medical officer.

Fort Hood is the same base where a military psychiatrist who proclaimed jihad against the U.S. killed 13 people 4½ years ago.

But military officials told NBC News the shooting appeared to have stemmed from a personal dispute at a motor pool and was unrelated to terrorism.

President Barack Obama spoke after the shooting, saying, "We're heartbroken something like this might have happened again."

He added, "We're following it closely. ... I want to just assure all of us we are going to get to the bottom of exactly what happened."

Defense Secretary Chuck Hagel, traveling in Hawaii, told reporters he had little information, but called the event a "terrible tragedy."

Witnesses and military officials said the shooting occurred about 4:30 p.m. (5:30 p.m. ET). The base's emergency alert system immediately sounded, and all personnel were told to shelter in place.

The "all-clear" siren wasn't sounded until about 8:45 p.m. (9:45 ET) — almost four hours after the base was locked down and sealed off.

Few details were immediately available, but a supervisor at Scott & White Memorial Hospital told NBC News that the hospital was "setting up a command center."

Bell County and state public safety deputies were securing the perimeter of the area, a senior local law enforcement source said.

The FBI was also on scene to support law enforcement, according to the sources.

Waco police told the public to avoid the fort, saying on Twitter that "there is an on-going active shooter."

Be AWARE!! If you are in the Ft. Hood Post area there is an on-going active shooter. Take shelter immediately and monitor media. — WacoPolice (@WacoPolice) April 2, 2014

Nevertheless, dozens of friends and relatives of Fort Hood personnel gathered in the base's visitors' center seeking information about loved ones, NBC station KCEN of Waco reported.

Antonio Ortiz, 30, who lives a quarter of a mile from the east gate of Fort Hood, said he heard a commotion and went outside to hear alarms going off and announcements for people to stay inside.

He went back in and turned on the TV news, then soon after heard a barrage of gunshots.

"It sounded powerful,” he said, adding that while it seemed to be coming from the base, he couldn't rule out the possibility someone in the civilian neighborhood was shooting.

"I’m scared for my son. He’s 7," Ortiz said. "But I do have a 12-gauge pump shotgun."

Central Texas College nearby was being evacuated, and all Thursday evening classes at the college and at Fort Hood were canceled, the college said.

And several lawmakers — in and out of Texas — called for prayers afterwards.

Maj. Nidal Hasan was convicted in August for killing 13 people in November 2009 and injuring 32 others. He has since been sentenced to death.

In September, a gunman opened fire at the Washington Navy Yard, killing 12 and wounding four before being slain by police. Last month, a civilian shot dead a sailor aboard a ship at a U.S. Navy base in Norfolk, Va.

Courtney Kube, Tom Winter, Tracy Connor, Hasani Gittens and Monica Alba of NBC News contributed to this report. This is a developing story. Refresh this page for more.