BOSTON — Police Commissioner Edward Davis, a key figure in the investigation of the Boston Marathon bombing, announced Monday he would step down after seven years on the job, saying it was time for a change for both him and the city.

Davis, 57, said he was “leaning heavily” toward accepting a fellowship at Harvard University but was entertaining other offers as well. He did not completely rule out the possibility of a federal post in the future, but said he was not planning on leaving the Boston area at this time.

Davis gained national stature following the April 15 bombing that killed three people and wounded more than 260 others, and the ensuing manhunt for the suspects. He twice testified before congressional panels in Washington, telling lawmakers that local officials had been unaware of information the Justice Department had prior to the bombing about Tamerlan Tsarnaev’s six-month trip to Chechnya last year.

Tsarnaev died following a shootout with police in neighboring Watertown on April 19, and his younger brother, Dzhohkar, was arrested later in the day.

“It’s time for me to try other things,” Davis said at a news conference at police headquarters in which he thanked Boston Mayor Thomas Menino, who appointed him in 2006, for showing him the importance of connecting with the community.

Davis said he would leave the post in the next 30 to 60 days, adding his exact departure date might hinge on the success of the Boston Red Sox. If the team was to advance to the World Series, Davis indicated he might stay on longer, presumably to coordinate crowd control in the event of a victory celebration.

Davis’ departure clears the way for the city’s next mayor to choose a permanent commissioner. Twelve candidates are vying in Tuesday’s preliminary election, with the top two vote-getters advancing to the Nov. 5 general election.

Menino announced in the spring that he would not seek a sixth term as mayor.

“Over the past seven years, Ed Davis has served the people of Boston with integrity, a steady hand and compassion,” Menino said in a statement Monday, adding that serious violent crime had decreased in the city during the commissioner’s tenure.

Davis, who came to Boston after heading the Lowell Police Department, said criticism of the police department’s record on diversity in the top ranks did not “in any way, shape or form” influence his decision to step down.

The department’s command staff is made up of 42 percent minorities, Davis said, though he acknowledged that more needed to be done to improve diversity in the department and placed some of the blame on the state’s rigid civil service requirements for police promotions.

Larry Ellison, a Boston police detective and president of the Massachusetts Association of Minority Law Enforcement Officers, said Davis had failed to show leadership in fully integrating the department.

“Civil service is a legitimate concern,” said Ellison. “It is a concern of ours as well, but the police department has not been as aggressive as it could have been in trying to remedy that.”

Davis said the response to the Marathon bombing showed city police could rise to any challenge, and that that the overall reputation of the force had been enhanced during his tenure.

“I leave the department on my own accord and I am very comfortable with the decision,” he said. “I want to clear the deck for a new administration coming in.”

Only subscribers are eligible to post comments. Please subscribe or to participate in the conversation. Here’s why.

Use the form below to reset your password. When you've submitted your account email, we will send an email with a reset code.