An off-duty Richmond police officer shot and killed a teenage boy after the boy allegedly pulled out a gun during the sale of an Xbox, police said.

The shooting occurred about 12:30 a.m. Monday in the parking lot of a shopping center in Chesterfield County, a suburb near Richmond.

Chesterfield police Major Frank Carpenter said the off-duty officer was an associate of a man who had agreed to sell the electronic gaming system to the teenager in the parking lot of the Chestertowne Shopping Center.

Carpenter said there was an exchange of gunfire between the officer and the teen when the boy pulled out a pistol.

"It was an attempted robbery by the juvenile," Carpenter said.

The officer, who was not wearing his police uniform, was shot in the torso but his wounds were not life-threatening. He was treated at a hospital and released.

The boy died at the scene. Their identities were not immediately released. No one else was injured.

Authorities are asking anyone with any information about the incident to call the department or an anonymous tips line.