Miami Beach Police Chief Ray Martinez will leave his post in early April, saying the time is right with new leadership in the city.

“I understand that the mayor and commission want to move in a new direction, and I respect that,” Martinez said.

Martinez, a 35-year cop who began his career in Miami, and joined the beach in 2001, shortly after the Elian Gonzalez saga, has no immediate plans and said he may take a teaching post at Florida International University.

He recently applied for chief of police job in South Miami, but was beat out by that city’s assistant chief, Rene Landa.

In a brief, three-paragraph statement, Miami Beach Mayor Phillip Levine said he was “grateful” for Martinez’s 2 1/2 year tenure as chief and that City Manager Jimmy Morales would work with an executive search team to find a new chief.

“We wish him the very best in his future endeavors,” Levine said of Martinez.

Still, at least one commissioner said it was likely Martinez decided to resign because of a lack of political backing.

“I certainly understand that he’s concerned that he doesn’t have political support,” said Commissioner Deede Weithorn.

Last year, after a series of embarrassments in various departments —including the police — voters chose a new mayor and replaced most of the commission.

Martinez’s resignation comes as an audit of the department is being wrapped up, after a series of police mishaps tarnished the department’s image.

Departmental blunders were spotlighted in 2011, when on Memorial Day Weekend, before Martinez became chief, officers fired 116 bullets at a drunk driver, killing him and wounding four bystanders. Just over a month later, two beach cops on duty were photographed partying with a group of young women.

One of them later drove a city-owned all-terrain vehicle on the beach, running over and seriously injuring two beach-goers. The department also faced accusations of gay-bashing.

When Chief Carlos Noriega left the city in the fall of 2011, Martinez was named chief.

In his resignation letter, Martinez cited achievements including officers not firing a bullet in more than two years, and reduced crime. Many credit him with calming the department.

“The police department is clearly now moving in the right direction,” said Martinez.

Yet there have been problems under Martinez.

In one instance a plainclothes detective was accused of roughing up a drunk model and kicking a man in the head after he tried to intervene. There is also the death of a teenage graffiti artist Israel Hernandez-Llach, who died after a lengthy chase, and after police used a Taser stungun on him.

In yet another embarrassment to the department, Morales yanked control of the 911 center from the police after a report broke showing employees who appeared to be sleeping on the job.

Still, most agree the department has taken a leap forward since Martinez was named its top cop.

“We want stability in our department, and I think in recent times we have accomplished that under Martinez’s leadership,” said Alex Bello, president of the Beach’s Fraternal Order of Police.