Starks on Wednesday signed a two-year contract with the Dolphins worth a maximum of $12 million.

It was a remarkable turn of events for Starks, who appeared destined to leave after six years with the Dolphins.

However, the market for defensive tackles was never as strong as he had hoped. The Dolphins always had interest in bringing him back, but at their price. On Tuesday, a return appeared possible, with the Dolphins working through the night to make it happen.

“It feels real good,” said Starks, who added that Miami was his first choice and that he didn’t visit any other teams, although he did have other options.

“Could be worse, I could be out on the street. Glad to be back.”

The proud Starks, who once flashed the bird in defiance after getting a sack in a game in which he didn’t start, is apparently OK with a pay cut. He played under the one-year franchise tag in 2013, earning $8.45 million.

With Starks’ return, the Dolphins again will have one of the league’s premier defensive lines. Cameron Wake, Olivier Vernon, Jared Odrick and Dion Jordan are all returning, and the Dolphins on Tuesday added former Houston Texans defensive tackle Earl Mitchell — named by ESPN’s Bill Polian as the best player available at his position.

“[Wednesday] shows a lot about our commitment up front,” Dolphins general manager Dennis Hickey said of Starks’ signing. “A two-time Pro Bowler, he can play the run, rush the passer. We’re very excited that we can bring him back and be part of a formidable front line.”

Starks ranked seventh among all interior linemen in 2013, according to Pro Football Focus. People close to the situation say there was friction between Starks and the Dolphins’ coaching staff — specifically coach Joe Philbin. Apparently they have put their differences aside for another run.