After a long, frustrating series of near misses, the Rockets on Saturday hit their trade target with a blockbuster trade that will go a long way to defining them for several years.

The Rockets acquired James Harden, last season’s NBA Sixth Man of the Year, from the Oklahoma City Thunder with the hopes he can be a much-needed, long-term star for their retooled roster.

“James is the foundational, franchise type player we have been seeking the past few seasons,” Rockets general manager Daryl Morey said. “He makes us better from day one and will play a big part in helping get us back to a championship level.”

The Rockets intend to sign Harden, 23, to a contract extension before the start of the season on Wednesday with plans to build around him, Jeremy Lin and Omer Asik.

To get Harden, the Rockets will send Kevin Martin, first-round pick Jeremy Lamb and two first-round picks to Oklahoma City.

“We are very excited with tonight’s trade,” Rockets Owner Leslie Alexander said in a statement. “While I never like having to send out quality players like Kevin Martin and Jeremy Lamb, this trade gives us a chance to make an immediate impact on the future of our franchise moving forward. James Harden was part of Team USA’s gold medal team at the London Olympics and is one of the most skilled shooting guards in the NBA. James, along with the mix of young players we already have in place such as Jeremy Lin, Chandler Parsons and Omer Asik give us a very solid group of young, talented players who will form the core of our team.”

The Thunder will receive the first-round pick the Rockets acquired from the Toronto Raptors for Kyle Lowry. The Rockets had acquired that pick to facilitate a blockbuster trade, initially hoping it could be the key to a deal for Dwight Howard. With the deal, the Rockets have in effect traded Lowry, Martin, their first of three 2012 first-round selections and other assets for Harden.

Oklahoma City would get the Raptors’ pick if it falls between four and 14 next season. If it doesn’t, it would get it if it’s between three and 14 the following two seasons. If they still have not gotten the pick, the Thunder would get it if it is between the second and 14th picks. If the Raptors make the playoffs for the next five seasons, Oklahoma City would get their pick the following season.

The Thunder will also receive the Dallas Mavericks pick, if it is not in the top 20, that the Rockets received from the Lakers for Jordan Hill. The Rockets are also sending Oklahoma City a second-round pick from Oklahoma City.

The Rockets will also receive center Cole Aldrich and forwards Lazar Hayward and Daequan Cook in the deal.

They made the move to acquire Harden, whom they considered a top free agent target for next summer if he could not reach agreement on a contract extension with the Thunder by Wednesday’s deadline and were budgeting to offer the sort of max contract they will now offer to sign Westbrook to an extension.

When the Thunder’s negotiations with Harden reached an impasse, trade talks with the Rockets picked up, with the Rockets willing to give Harden the contract the Thunder would not with Russell Westbrook and Kevin Durant already in place as their foundation.

Harden averaged 16.8 points, 4.1 rebounds and 3.7 assists last season, his third out of Arizona State, making 49.1 percent of his shots.

Martin has been the Rockets’ leading scoring in each of the past three seasons and in the preseason and has career averages of 18.4 points, 3.5 rebounds and 2.1 assists, Lamb was the 12th player taken in the 2012 draft, with the Rockets sending Samuel Dalembert to the Bucks several days before the draft to position themselves to take Lamb.

Martin said he was “very happy” but that the news was still “bitter sweet.

“Sometimes you just can’t describe how you feel in words,” Martin said. “Very surreal feeling.”

Thunder general manager Sam Presti said the deal was made because of the inability to reach agreement on a contract extension with Harden.

“We wanted to sign James to an extension, but at the end of the day, these situations have to work for all those involved,” Presti said in a statement. “Our ownership group again showed their commitment to the organization with several significant offers. We were unable to reach a mutual agreement, and therefore executed a trade that capitalized on the opportunity to bring in a player of Kevin’s caliber, a young talent like Jeremy and draft picks, which will be important to our organizational goal of a sustainable team.”