The Texas church gunman was able to buy firearms despite being court-martialed for domestic abuse, after the Air Force failed to enter his charges into the federal database.

The blunder allowed Devin Patrick Kelley, 26, to pass all his background checks and legally purchase the Ruger AR-556 rifle which he used to mow down parishioners in Sunday's deadly attack.

Kelley, who served in logistics readiness at Holloman Air Force Base in New Mexico from 2010-2014, was court-martialed in 2012 on charges of assaulting his spouse and his stepson who was left with a fractured skull.

He was confined for twelve months at Naval Consolidated Brig Miramar in California as punishment, before being released from the military with a bad conduct discharge in 2014.

In Texas, anyone convicted of serious domestic assault is barred from buying a firearm until the fifth anniversary of their release from confinement, while federal law permanently bans domestic abusers from owning a gun, although law generally defers to state.

In this case, Kelley's criminal record should have prevented him from being able to buy a gun until at least 2019. But the Air Force's failure to enter his domestic charges into the federal database meant that he passed all his background checks with flying colors and was able to buy four guns between 2014 and 2017.

Devin Patrick Kelley (pictured left, and in a mugshot from a previous crime) walked into the First Baptist Church of Sutherland Springs, dressed in full combat gear, and began shooting, according to local law enforcement sources

Kelley had recently posted a photo of an AR-15 style gun on his Facebook page with the caption: 'She's a bad b***h'

They include the Ruger AR-556, which he bought from an Academy Sports & Outdoors store in San Antonio in April 2016, which was later used in the massacre at First Baptist Church in Sutherland Springs, Texas.

He also bought the 9mm Glock and a Ruger 22 which were found inside his vehicle near his body.

The Air Force has since ordered a 'comprehensive review' into why Kelley's charges were not entered into the National Criminal Information Center database to ensure no other criminals have been missed.

In a statement, the Air Force said: 'Initial information indicates that Kelley’s domestic violence offense was not entered into the National Criminal Information Center database by the Holloman Air Force Base Office of Special Investigations.

'The Air Force has also requested that the Department of Defense Inspector General review records and procedures across the Department of Defense.'

The shooting happened at the First Baptist Church of Sutherland Springs (pictured), where around 50 people usually attend service, according to local reports

Investigators work at the scene of a deadly shooting at the First Baptist Church in Sutherland Springs, Texas, Sunday

But the admission raises important questions over why communication between the Air Force and the government failed - and how many other airmen with criminal convictions could have gone unreported to the federal database.

Kelley bought two guns in Colorado and anther two in Texas after his release in 2014.

Neither state requires individuals to have a license or registration to buy guns, but Colorado ranks high on the list of easiest places to purchase a firearm.

Academy Sports + Outdoors released a statement to the DailyMail.com on Monday.

'Based on information we received from law enforcement, we confirmed that the suspect purchased two firearms from two San Antonio locations, one in 2016 and one in 2017.

'We also confirmed that both sales were approved by the National Instant Criminal Background Check System (NICS). We are cooperating with law enforcement as they investigate further,' the statement read.

The company also sent their 'deepest condolences to the families of the victims and the entire Sutherland Springs community'.

Kelley, 26, managed to purchase the Ruger AR-556 rifle in April 2016 from an Academy Sports & Outdoors store (file image) in San Antonio, according to a law enforcement official

Kelley used a Ruger AR-556 rifle (file image) in the deadly church attack in Texas. He was able to purchase the gun because he received a bad conduct discharge from the Air Force instead of a dishonorable discharge for domestic abuse

Law enforcement officials also confirmed that Kelley completed the NCIS check to buy the rifle. However, the bad conduct military discharge didn’t show up as a prohibited offense.

According to Allison Anderman, the managing attorney at Giffords Law Center to Prevent Gun Violence, dishonorably discharged military members cannot legally purchase a gun.

And Kelley's bad-conduct discharge fell just short of that mark because he was charged under a special-court martial and not a general court martial, which is the highest punishment for rape, murder or other serious crimes.

'It seems as though from what we can tell now that the bad conduct discharge was not something that the Department of Defense reported to the NICS,' Anderman said, noting that it is still too early in the investigation to be sure.

However, the domestic abuse charges should have been.

'If those records were not reported then they [NICS] wouldn't have access to them,' Anderman said, noting that the NICS check is the system the gun store used when Kelley purchased the rifle.

Authorities said during a press conference Monday morning that Kelley held a private security license because he worked as a nighttime security guard at Schlitterbahn New Braunfels within the last five and half weeks.

A victim is evacuated from the First Baptist Church of Sutherland Springs after the massacre on Sunday afternoon

A private security license requires individuals to pass a criminal background check whether they carry a gun or remain unarmed during their shifts.

Kelley was an unarmed guard at the water park and his duties included checking gate locks at night.

He started there in June, but was terminated shortly after. Details surrounding his termination have not been revealed.

Texas Gov Greg Abbott, citing the Texas Department of Public Safety (DPS), told CNN Monday morning that Kelley tried to get a license to carry a gun in Texas but the state denied him.

According to Anderman, the state could have denied Kelley from obtaining that license if they had reason to believe he was not 'capable of exercising sound judgement for the proper use and storage of a handgun'.

And those reasons can vary based on what records the state had access to when reviewing Kelley's application.

Records show Kelley was charged with cruelty to animals, a misdemeanor, in August 2014. The case was later dismissed.

An aerial photo shows the site of the mass shooting at the First Baptist Church of Sutherland Springs

Kelley, who is suspected of a mass shooting at the First Baptist Church of Sutherland Springs resided at this home in New Braunfels

It's still unclear when Kelley attempted to get a license to carry a gun in Texas, but if he tried to get the license after he was charged with animal cruelty and before the case was dismissed, that could have led to his denial.

Kelley walked into the church dressed in black, tactical gear with a ballistics belt and the assault rifle, and opened fire during Mass just before 11.30am Sunday morning.

The attack only stopped when Kelley, of New Braunfels, a suburb of San Antonio, was confronted by local hero Stephen Willeford, 55, who shot him through a gap in his body armor as the gunman tried to leave the church.

Kelley fled in his car, lost control in his vehicle and was found dead inside by authorities.

Victims of the horrific shooting include a two-year-old girl and the 14-year-old adopted daughter of the pastor.

Eight members of one family, including a eight-months-pregnant mother and three of her children were killed, a community leader and relative told CNN, without revealing their identities. The Connally Memorial Medical Center said 'multiple' victims are still being treated.

Last night, San Antonio police raided Kelley's home with K9 and bomb squad units, along with agents from the Bureau of Alcohol, Tobacco, Firearms and Explosives unit and FBI.

Mourning: Local residents embrace during a candlelight vigil for victims of the mass shooting in Sutherland Springs, Texas

Grief: Hundreds gathered to pay respect to those killed in the massacre. Many held candles aloft as they staged the moving vigil

Prayers: A man raises his right hand and bows his head along with others who gathered to pay respect to those killed in the shooting

Kelley was also a former Bible studies teacher but his Facebook page, which has been deleted by the FBI, reveals he had a worrying fascination with weaponry.

He'd recently shared a photo of an AR-15 style gun on Facebook with the caption: 'She's a bad b***h.'

The 26-year-old was married to Danielle Shields, and they appear to have a child together. She was previously a teacher at the First Baptist Church.

Kelley lived at his parents' home with his wife and child, and neighbor Mark Moravitz told ABC News he would sometimes hear gunshots coming from near the house late at night.

Kelley volunteered as a teacher for Bible studies at Kingsville First Baptist Church, according to his LinkedIn which shows him posing with a young child.

He was reportedly employed by Schlitterbahn Waterpark and Resort in New Braunfels and licensed by the Texas Department of Public Safety as a security guard at the time of the shooting.

Former classmates described him as 'creepy', 'crazy' and an 'outcast' who had recently started preaching about atheism and picking fights on social media.

However, local law enforcement say he had a relatively clean criminal record, with just a traffic offenses in recent years.

Police are now investigating the possibility that Kelley was in a local militia group.

Annabelle Pomeroy was the first victim identified after the shooting on Sunday.

Her father, Frank Pomeroy, who is the church pastor - had been out of town during the attack. The grieving dad told ABC he's lost 'one beautiful girl, and a 'special child'.

First Baptist Church Pastor Frank Pomeroy's (right with his wife Sherri) 14-year-old adopted daughter, Annabelle (left), was killed in the shooting

Sunday school teacher Karla Holcolmbe and her husband Bryan also died in the rampage, their family confirmed. A local resident says their pregnant daughter-in-law was also killed

Crystal Holcombe (left) was married to Bryan and Karla Holcombe's son John (right) and had been at church with her in-laws when she was shot dead

Mother-of-four, Joann Ward (pictured), is said to have died in the wake of the shooting, according to her family

Sisters six-year-old Brooke (left) and eight-year-old Emily Garza (pictured, right, sitting on the right, next to her sister Rihanna) were killed in the shooting according to her family. Nine-year-old Rihanna (sitting next to Emily had her glasses shot off her face but survived

Bryan Holcombe had been standing in for Frank Pomeroy as pastor when Kelley opened fire. Witnesses say he was the first victim to be struck by the shooter's gunfire.

'Bryan was filling in,' the witness, who did not want to be named, told DailyMail.com. 'He was walking up to the pulpit when he was shot in the back.

'He was an awesome Christian,' they added.

He was killed, alongside his wife of 25 years, Sunday school teacher Karla Holcombe, as well as their daughter-in-law Crystal, a mom-of-five who was eight-months-pregnant, local residents reported. There are reports that three of Crystal's children were also killed.

The couple ran a canvas repair shop before retiring and had attended the church for 25 years.

'My father was a good man and he loved to preach. He had a good heart. They knew where they were going. There's peace in that,' their son Scott Holcombe told the Herald-Tribune.

Mother-of-four Joann Ward and three of her children were also shot. Family have since told the Dallas News that Joann and two of her daughters, six-year-old Brooke and eight-year-old Emily have died.

Kelley, (pictured in his yearbook photo, left and right, as a teenager) 26, of New Braunfels, a suburb of San Antonio, fled in his SUV but crashed near county lines

Police have not yet released a motive for why Kelley, (pictured recently) opened fire at the church

RUGER AR-556 IS A VARIANT OF AR-15 USED IN MASSACRE Devin Patrick Kelley isn't the first gunman to use AR-15 variants to gun down men, women and children. Rifles based on the AR-15 were used in the mass shootings in Newtown, Connecticut; Aurora, Colorado; and San Bernardino, California. The Orlando shooter used a Sig Sauer MCX, which is a weapon with different characteristics but based on similar concepts to the AR-15. According to the National Rifle Association website: 'The AR-15’s ability to be modified to your own personal taste is one of the things that makes it so unique.' The AR-15 is a category and not necessarily a specific weapon. It is known for having hundreds of variants, each with its own characteristics. Sales of the gun traditionally have spiked after each mass shooting. It's estimated that between 5 million and 8 million AR-15 variants are owned in the United States. The weapon did not reach popularity until the expiration of the nation’s federal assault weapons ban in 2004. Advertisement

Ward's five-year-old stepson Ryland, who was shot four times, is still in hospital after undergoing emergency surgery. The mom's eldest daughter Rihanna, nine, had the glasses shot off her face but escaped injury by hiding under a pew as shots rang out.

Footage from Ksat showed families weeping as they waited to discover if relatives were victims.

The gunman was spotted moments before the shooting, at around 11.20am, at a Valero gas station, 'dressed in all black, tactical gear, wearing a ballistics belt'.

In a press conference, Texas Department of Public Safety Regional Director Freeman Martin, said Kelley had then 'crossed the street to the church, exited his vehicle and began firing on the church'.

'He moved to the right side of the church and continued to fire, and entered the church and continued to fire,' Martin added.

But as he left the church, Willeford risked his life to stop him.

'A local resident grabbed his rifle and engaged the suspect,' Martin said. 'The suspect dropped his rifle, which was a Ruger assault type rifle, and fled from the church. A local citizen pursued the subject at that time.'

Willeford, who has no military experience, didn't hesitate when came face to face with Kelley, and shot him in between Kelley's body armor, hitting him in his side.

The 26-year-old had dropped his Ruger assault rifle and climbed in an SUV to flee the scene.

Another local resident, Johnnie Langendorff, had stopped at the gas station across the street to get breakfast when he noticed the gun fight at the church.

He says he saw Kelley leave the church as he was being pursued by Willeford.

When Kelley took off in his car, he says Willeford came over to him, told him what was going on and said that they needed to chase after him.

Langendorff agreed, and the two started speeding at 95mph to catch up to the suspect. All the while, Lagendorff was on the phone to dispatch, letting officers know their location.

Law enforcement tracked down the suspect, who went off the road and crashed near county lines. Pictured is the suspect's car which was found with multiple weapons inside it

Stephen Willeford, 55, (left) and Johnnie Langendorff (right) have been praised as heroes after they were able to stop Texas gunman Devin Kelley's rampage

As they approached a sharp curve in the road, near the 307 and 539, in Guadalupe County, he said Kelley appeared to lose control and his car swerved off the road.

'It's like he just gave up. He just kind of went off in the ditch, hit a hay bale from what I could see and then he just never moved after that. He didn't get out. He didn't try anything. Nothing.

'When he hit the ditch the gentleman that was with me got out, rested his rifle on my hood and kept it aimed at him - telling him to 'Get out, get out'. There was no movement there was none that. They guy didn't put up a fight or anything like that

'Once police showed up they moved me and the gentleman back and then everybody showed up and they took action,' Lagendorff said.

Cops found Kelley dead inside, along with multiple weapons and possible explosives. It's still unclear how he died.

'We are not sure if it was self inflicted or if he was shot by a local resident,' Martin said.

San Antonio police also raided Kelley's home on Sunday evening, with K9 and bomb squad units, along with agents from the Bureau of Alcohol, Tobacco, Firearms and Explosives unit and FBI.

Martin said that 23 found dead inside the church, and another two bodies were recovered from outside the building. Another person, who was taken to hospital, died while receiving treatment.

Injuries range from minor to very severe, while victims were aged from five-years-old to 72.

It's not yet clear how many were in church at the time of the shooting but Martin said some escaped unhurt.

Texas Gov Greg Abbott participated in a candlelight vigil for the victims of a fatal shooting at the First Baptist Church in Sutherland Springs, Sunday

Abbott consoled Ann Montgomery, a Sunday school teacher at First Baptist Church, during the candlelight vigil

Annabell Pomeroy, (left) the 14-year-old daughter of the church pastor, was the first victim identified in Sunday's shooting. Five-year-old Ryland Ward, (right) the stepson of feared-dead mother-of-four Joann Ward, was shot four times and is in surgery

It is believed to have been the worst shooting at a place of worship in American history.

Residents of the community gathered for an emotional candlelight vigil on Sunday night as the names of the victims began to emerge.

Sutherland Springs is a rural community in Wilson County, Texas, that's made up of about 400 people. It's located about 30 miles southeast of San Antonio. There are 11 hotels in the area, and there used to be a 52-floor facility, but it closed in 1923.

Texas Congressman Vicente Gonzalez told MSNBC that based on what he knew, he did not believe the incident was related to terrorism, but 'was some kind of other incident that has to do with the church or the community'.

Carrie Matula, who works at a gas station near the church, told MSNBC that she heard 'semiautomatic gunfire' and looked to see what was going on.

'I never thought it would happen here,' Matula said. 'This is something that happens in a big city. I would never have thought this would have taken place here. It's just too tight a community. It doesn't make sense.'

Carrie Matula (left) embraced a woman after the deadly shooting at the First Baptist Church in Sutherland Springs. Matula said she heard the shooting from the gas station where she works a block away

Photos showed families tearfully praying outside their community building as they wait to see if their family and friends are safe

People gathered near First Baptist Church following a shooting on November 5, 2017 in Sutherland Springs, Texas

Law enforcement officers stand in front of the First Baptist Church of Sutherland Springs

The shooting took place at the churchl, which is located about 30 miles from San Antonio. Sutherland Springs is a community of about 400 people

President Donald Trump, who is visiting Japan, sent his condolences to the Sutherland Springs community.

'Victims and their families were in their sacred place of worship. We cannot put into words the pain and grief we all feel,' he said in a televised statement from Japan, urging everyone to 'stand strong, oh so strong.'

'In dark times such as these, Americans do we what do best and we pull together. We lock hands and we joins arms. Through the tears and through the sadness we stand strong.'

He went on to say that the worst mass shooting in Texas history is a 'mental health problem at the highest level'.

Speaking at an event with the Japanese prime minister in Tokyo on Monday, Trump described the gunman as a 'very deranged individual'.

Abbott released a statement following the shooting.

'While the details of this horrific act are still under investigation, Cecilia and I want to send our sincerest thoughts and prayers to all those who have been affected by this evil act.

'I want to thank law enforcement for their response and ask that all Texans pray for the Sutherland Springs community during this time of mourning and loss.'

Texas Attorney General Ken Paxton said in a statement: 'The thoughts and prayers of all Texans are with the people of Sutherland Springs as tragic reports come out of First Baptist Church.'

'Please join Angela and me as we pray for those impacted by this horrific shooting,' Paxton said.

Special agents from ATF's Houston Field Division, San Antonio Field Office were also on the scene along with the FBI.