The female off-duty D.C. police officer who came under fire early Wednesday while driving along Suitland Parkway in Southeast Washington had been at the same nightclub as the man arrested in the case, according to an arrest affidavit filed in D.C. Superior Court.

Authorities do not say in the document whether the 12-year veteran knew or had a run-in with the suspect, Romeo Hayes, 27, of Southwest Washington. Shortly after firing at the officer, police said, Hayes and others tried to carjack an off-duty District detective and shot him four times.

The new details are among the first to help explain the unusual shootings early Wednesday involving the two off-duty officers. Gwendolyn Crump, a police spokeswoman, declined to elaborate on the affidavit, citing the ongoing investigation. The female officer declined to comment.

Hayes has been charged with two counts of assault with intent to kill. A D.C. Superior Court judge ordered him detained until a preliminary hearing Sept. 2. His attorney, Maneka Sinha, argued that police lacked enough evidence to arrest him and said police did not find a gun. A relative at Hayes’s home in Southwest declined to comment.

According to the arrest affidavit, Hayes was at Opera Ultra Lounge on First Street NW, near Union Station, and left about 2:30 a.m. The document states that “this establishment is the same location [the female officer] was at prior to the shootings.” It does not say when the officer left.

D.C. police reported a surge in carjackings and shootings that began Friday night and continued into the new week. The carjackings occurred in Police Districts 6 and 7, historically the city’s most violent precincts; the shootings were scattered across much of the city. Despite, the recent outburst, violent crime is generally down this year compared with the same period last year. Homicides, however, are an exception. There have been at least 15 more homicides citywide this year than had been reported at this time last year.

Authorities said the two encountered each other about 2:45 a.m. as the officer drove along Suitland Parkway, toward Maryland. Near Alabama Avenue, six miles from the club, the officer heard gunshots from a burgundy Nissan Altima behind her, according to the affidavit. Police said that the Altima’s driver moved alongside the officer’s car and that three more shots were fired. A bullet hole was found in the back of the officer’s car, they said.

The officer chased the Altima, which had been stolen from Reagan National Airport, but couldn’t keep up, police said. They said the Altima next appeared at Pennsylvania and Southern avenues, where it cut off the detective, who had stopped his SUV at a light.

The detective heard an occupant say, “Let’s take his car,” and he said he replied, “Not today,” the document says. The front-seat passenger in the Altima pointed a gun out the window and fired one shot. The detective rammed the Altima, and authorities said the passenger opened fire again. Both cars sped along Southern Avenue, hitting each other, with the gunman firing along the way, according to the affidavit and police. Twelve bullets hit the detective’s SUV; he was struck in the left side of the chest, left shoulder, left arm and abdomen. He is recovering from his injuries.

The Altima then sped into Prince George’s County, where an officer spotted it and chased it back into the District. The pursuit ended when the Altima hit a fence in Northeast and three people ran from the car. Only Hayes was arrested; police are searching for the others.

The shootings of the detective and the attack on the other officer came amid a spike in crime that has left 21 people shot — one fatally — and several carjacked since Friday night.

Authorities are investigating whether any of the gun violence is related. Hayes lives in a house where six people were shot Sunday in what authorities described as a gun battle. It has no apparent connection to the incidents involving the officers.

Sunday’s shooting occurred about 1:45 a.m. on N Street Southwest, two blocks from Nationals Park. A search-warrant application filed in D.C. Superior Court says that shots were fired at the house and that at least one person outside returned fire. Police officers who rushed into the house reported finding a trail of blood from the front dining room to the rear kitchen as well as blood on a fence post in the back yard.

The court documents say that inside, police found a black handgun loaded with eight bullets and assorted ammunition for various-caliber weapons. No arrests have been made.

Clarence Williams contributed to this report.