Dallas police said they are questioning a person of interest in the shooting of an officer early Tuesday morning.
U.S. marshals took the man into custody in Farmers Branch at about 11 a.m. on a parole violation.
The man has not been named a suspect in the shooting and has not been charged in the shooting.
Investigators said Senior Cpl. Matthew Wagner was shot at about 12:30 a.m. and hospitalized with serious injuries. He is recovering from gunshot wounds to his arm and hip area.
"We're very, very, very lucky that he survived this ordeal," Dallas Police Chief David Brown said.
Wagner and Sgt. Rodney Choate were in uniform while working off-duty security at Wildflower Apartments in Five Points.
The officers spotted a suspicious man in the back seat of a minivan and discovered he had binoculars and had been listening to a police scanner.
The chief said the man fought back when the officers tried to search him or weapons. During the struggle, the man pulled out a gun and shot Wagner, Brown said.
The four-year department veteran has a broken arm from the bullet.
As the man ran away, he opened fire again, hitting Wagner a second time. But his pepper spray canister slowed down the bullet, which exploded the pepper spray and then continued to travel to his groin area.
Brown said he believes it helped save Wagner's life.
"It traveled into his groin area near that large artery that we have," he said. "That can be devastating. Again, we feel quite blessed that we were able to survive this, even though this officer experienced a lot of pain and, obviously, experienced a lot of loss of blood."
Fellow officers rushed the wounded Wagner to Texas Health Presbyterian Hospital Dallas, which is just a few blocks away.
Wagner's wife, Sarah, posted on the Dallas Police Department's Facebook page: "Thank you God for being next to my husband last night. Now with God, Team Wagner will recover."
"He says it hurts, but he's happy all he has is a broken arm and pain; so are we," Brown said.
An intense search of the apartment complex turned up empty-handed. At about 7 a.m., heavily armed officers surrounded a home on Army Avenue in West Dallas looking for the gunman.
The homeowner told NBC 5 that the man wasn't there.
"We're going to do everything in our power to bring this suspect into custody and bring him to justice for what he's done," Brown said.
Police are not releasing any more details on the person of interest.
Police towed the minivan from the scene of the shooting. Investigators also have the shooter's gun, which he dropped while he was running away.
The chief said he knows his officers put their lives on the line every day, but Tuesday's shooting was a close call.
"If it weren't for our officers willing to lay down their lives to protect this city, we would not be safe," he said. "It takes this kind of sacrifice, this kind of effort, to keep the city save. The officer’s bravery and courage and dedication in protecting the city is unheralded. I'm always impressed with Dallas officers' willingness to lay down their lives to protect this city. Thank God we didn't have to give our lives in this instance."
Brown told NBC 5 that Wildflower Apartments has problems with drugs, robberies and other crimes. Management had hired the off-duty officers to make the complex safe. It's in one of the most dangerous "hot spots" in the city.
Dallas police are putting more officers in the Five Points area and rolling out new technology to cut down on crime, Brown said.
NBC 5's Kendra Lyn and Randy McIlwain contributed to this report.