A Miami-Dade police officer was justified when he shot and wounded a teen who wielded an aluminum baseball bat under his clothes during a 3:30 a.m. encounter in West Kendall, prosecutors say.

The officer: Luis M. Perez, who shot Sebastian Gregory, then 16, during a stop in May 2012. The teen, who suffered four gunshot wounds, now has one leg paralyzed and suing the officer and Miami-Dade police.

According to a final report by the Miami-Dade State Attorney’s Office released Friday, Perez saw Gregory — wearing all black with a black cap on his head and a “bulge” under his clothes — walking down the street in the middle of the night.

Perez later said knew Gregory as a member of a gang called South Park Nation and the teen was under investigation for several burglaries.

The officer stopped Gregory on the 15900 block of 72nd Ave. and ordered him to the ground. As the teen got on the ground, Perez noticed the “shiny” object in his pants, according to the report.

As Perez was radioing in to dispatchers, according to prosecutors, the teen made a “sudden move” toward the object.

“He rolled on his left side … simultaneously as he’s rolling he reached with his right hand, grabbed the shiny metallic object, which I thought was a gun,” the officer told detectives. “In fear he was going to pull out a gun and shoot me, I fired my weapon at the threat.”

The object turned out to be a 16-ounce Easton Hammer aluminum baseball bat.

Because of the perceived threat to Perez, the State Attorney’s office deemed the shooting “legal and justified.”

The teen, in a local TV news interview earlier this year, claimed he had the baseball bat for protection from bullies. But the officer told investigators he knew the teen from several earlier middle-of-the-night encounters.

Perez had arrested the teen in April 2012 after Gregory, wearing all black, ran from him at 2:56 a.m. The cop found a 3-foot metal baseball bat and two 8-inch knives in his pockets, according to the report. Gregory was charged with carrying a concealed weapon.

One month earlier, Gregory was arrested and charged with criminal mischief after he admitted to using a hammer to shatter the glass of a bank drive-through and several storefront windows on four separate occasions.