Two people were killed and 14 others wounded when a gunman opened fire at a packed bar in downtown Austin early Sunday — and the FBI is now probing the shooting as potential terrorism.

The shooter, identified as Ndiaga Diagne, formerly of The Bronx, was killed minutes after the carnage by responding cops.

“There were indicators that on the subject and in his vehicle that indicate potential nexus to terrorism,” said Alex Doran, a special agent with the FBI’s San Antonio field office, to reporters.

Ndiaga Diagne has been identified as the shooter who killed two people and injured 14 others at a bar in Austin, Texas. Obtained by the NY Post

Police officers guard the scene on West 6th Street at West Avenue after the shooting in Austin, Texas. AP

“Again, it’s still too early to make a determination on that,” he said — although the FBI’s Joint Terrorism Task Force has joined the investigation into the mass shooting.

Police responded to reports of a male shooting at Buford’s Backyard Beer Garden — near the University of Texas-Austin — just before 2 a.m., officials said at a press conference.

Three officers who were on routine patrol of the entertainment district responded to the scene within 57 seconds, confronted the gunman and “returned fire,” killing him.

Diagne, a US citizen from Senegal, began shooting people outside the bar with a handgun and an assault rifle, according to the Austin-American Statesman.

“He put his flashers on, rolled down his window and began using a pistol, shooting out his car windows, striking patrons of the bar that were on the patio and were in front of the bar,” said Austin Police Chief Lisa Davis.

Moments before the shooting, a crowd was enjoying live music on a packed dance floor. Instagram / Bufords Austin

The killer then drove down the block and, “Once again, he starts shooting some people that are walking by.’’

Two victims died at the scene.

The gunman had a Quran in his car and was dressed in clothing described as Islamic garb when he began firing into the crowd.

Sources told The Post he was possibly motivated by the US strikes against Iran.

He has a history of arrests in New York City and Texas. He is believed to have lived in New York City for years, racking up at least four arrests starting in 2001 and spanning up to 2016, sources said.

Most of the arrests were sealed, but one was for illegal vending.

First responders arrived at the Texas shooting scene in less than a minute, rushed 14 other patients to nearby hospitals.

Three of those victims are listed in critical condition, officials said.

None of the victims has been identified so far.

Just hours before the shooting, the popular bar shared videos on its Instagram story showing the bar jam-packed with young revelers drinking and dancing to a DJ.

Officials noted federal agents were helping with the investigation. AP

Two people were killed and 14 others were wounded in the attack, before the gunman was also shot dead. CBS Austin via FOX San Antoniio

The clips show the unsuspecting crowd belting out Miley Cyrus’ “Party in the USA” and Kelly Clarkson’s “Since You Been Gone” as they’re blasted by a smoke machine.

The bar, which is open between 12 p.m. and 2 a.m. on the weekends, was gearing up to close for the night when gunfire erupted.

“Our hearts go out to the people that are victims of this and I want to reiterate my thanks to our public safety officers and officials that so rapidly were on the scene, they definitely saved lives,” Austin Mayor Kirk Watson said.

An Austin police officer guards the scene on West 6th Street. AP

“Today is a difficult day for our city and the University. We are deeply saddened by the tragedy that occurred early this morning in downtown Austin,” said Jim Davis, president of University of Texas at Austin, which sits just up the street from Buford’s.

“Our prayers are with the victims and all those impacted, including members of our Longhorn family. We are also grateful to the first responders who acted quickly to save lives, and to our UT counselors and staff members who have provided care and support throughout the day,” he wrote on X.

Moments before the shooting, revelers were enjoying live music on a packed dance floor, according to video posted to the beer garden’s social media.

Buford’s, a large night-life bar, can hold up to 700 people and features a stage, basketball, skeeball and video games.

Buford’s Backyard Beer Garden did not respond to The Post’s request for comment.

The Austin Police Department told community members searching for loved ones who were at the shooting to contact the APD’s Victim Services Unit at 512-974-5037.