Police say a man has been charged in a shooting that injured an off-duty Chicago police officer during an attempted robbery.

Chicago police spokesman Anthony Guglielmi said Samuel Harviley has been charged with attempted murder in the early Monday shooting.

Police have said the officer, who was shot in the leg, was sitting in his car near his home when two men with handguns approached and told the officer they were going to rob him.

Interim Police Superintendent John Escalante has said the officer was "trying to comply" with demands of the gunmen but pulled out his service weapon and exchanged gunfire with at least one of the men when one told the other to shoot him.

It wasn't immediately known if Harviley has an attorney who could comment on his behalf.