A 2-year-old boy has died from a gunshot wound to his head and his father has been charged with endangering the welfare of a child, Bucks County District Attorney Matt Weintraub said Thursday.

Jorddan Thornton, 27, was taken into custody Wednesday night in the death of his son Julius, who would have turned 3 on Christmas Eve, Weintraub said.

The shooting occurred Wednesday inside a residence at the Racquet Club Apartments on Veterans Highway in Middletown Township.

Weintraub said authorities are still investigating and it’s unclear whether the boy may have shot himself, or if the father accidentally or intentionally shot him. The two were alone in the apartment at the time of the shooting, he said.

The child’s mother, who was not home, is cooperating with authorities, Weintraub said.

Middletown Township Police Chief Joe Bartorilla said Thursday night that Thornton, who also has a Philadelphia address, has a legal permit to carry a gun out of Philadelphia.

A neighbor in the apartment building called 911 after Thornton came out of his apartment holding his son, Weintraub said.

Middletown Township police arrived about 8:50 p.m. The father, who was distraught, told police his son “jumped and fell off a bed, but that is clearly not the case,” the DA said.

The boy was taken to St. Mary Medical Center, where he was pronounced dead.

Another neighbor told police she heard what sounded like a gunshot, ran out of her apartment, and saw a man with a child in a white towel. She said she heard the man telling the child, “I’m sorry,” according to the affidavit of probable cause for Thornton’s arrest.

Thornton told police there are guns at the apartment, but said they were put away in drawers, the document says.

Thornton remained in custody at the Bucks County Correctional Facility on Thursday on $500,000 bail. He is being represented by the public defender’s office, which could not be reached for comment Thursday.

He has a preliminary hearing scheduled for Dec. 16.