A police manhunt in Houston, Texas for a gunman accused of shooting a police officer ended on Friday night after the suspect turned the gun on himself.

The Houston Police Department says that an officer responded to an apartment complex after shots were heard in the area on Saturday morning around 2 a.m., according to KRIV-TV. The unidentified officer called for backup after hearing more shots coming from inside one of the apartments at which point the officer was shot in the leg by an unidentified gunman.

Police Chief Troy Finner said the officer suffered injuries in both legs but was "in great spirits" after being taken to the hospital.

The officer has been released from the hospital and is recovering at home.

HOUSTON GIRL, 9, 'EXECUTED' BY MOTHER'S EX-BOYFRIEND, SUSPECT ON THE RUN, POLICE SAY

Houston Texas skyline at dusk

Houston, Texas skyline (Getty Images)

It is not believed that the officer returned fire on the gunman.

After a perimeter was established to locate the shooter, it was discovered that the gunman had barricaded himself in the apartment.

HOUSTON MEN STEAL $4,200 LIQUOR BOTTLE THAT TURNS OUT TO BE CHEAP DECOY

Houston Police car

A Houston police car in front of a graffiti-covered building in the Old Chinatown section of downtown  (Timothy A. Clary/AFP via Getty Images)

Police later confirmed, after a standoff that lasted several hours, that the shooter had died from what appeared to be a self-inflicted gunshot wound.

Houston, Texas, USA downtown city skyline over Root Square.

Houston, Texas, USA downtown city skyline over Root Square. (iStock)

CLICK HERE TO GET THE FOX NEWS APP

The Houston Police Department did not immediately respond to a request for comment from Fox News Digital.