RIO DE JANEIRO - The United States continued their reign over Spain with a scrappy 82-76 win on Friday to put them through to the gold medal final of the men's basketball tournament for a third straight Olympics.

The Americans will ride a 24-game Olympic winning streak into Sunday’s final where they will face the winner of Australia and Serbia, who play later on Friday.

With the two top-ranked teams, No. 1 U.S. and No. 2 Spain, both packed with NBA talent, the game had the familiar buzz of a gold medal final. The countries met to decide the gold at the previous two Olympics in London and Beijing, with the U.S. coming out on top both times.

“What I would say it was a very hard game,” U.S. coach Mike Krzyzewski told reporters. “It wasn’t easy flowing and both teams had to make big plays.

“I thought our guys did that a little bit more than they did.”

The United States led from the opening tipoff but were never able to run away from a Spanish squad determined to end decades of frustration that has seen them lose all 12 meetings with the U.S. team on Olympic or world championship hardwood dating back to 1936.

After constructing a 26-17 first quarter lead the U.S would push into double digits in a stop and start second as referees robbed the contest of any rhythm by calling a string of technical fouls that had both coaches and fans expressing their unhappiness.

The U.S. held 10 point or more leads in the second, third and fourth quarters but each time Spain would claw their way back into the game, keeping the outcome in doubt although the United States never appeared in danger of losing control.

Klay Thompson broke out of his Olympic scoring funk in a big way, dropping a team high 22 points, while Kevin Durant chipped in with 14.

But it was the improved U.S. defensive play, and the work of DeMarcus Cousins on the boards pulling down 16 rebounds, that were singled out for praise.

“To win gold we need to continue to make that effort on the defensive end, and if we play with passion like tonight, we will be tough to beat,” Durant told reporters. “On the defensive end tonight and the last two games, we were really good.

“This is where we wanted to be.”