1 of 4
Charlie Neibergall, Associated Press
Spain players celebrate after the bronze medal basketball game against Australia at the 2016 Summer Olympics in Rio de Janeiro, Brazil, Sunday, Aug. 21, 2016.

RIO DE JANEIRO — Not golden, not the Olympic medal it still covets, but Spain got something.

Australia would take anything.

Pau Gasol scored 31 points in perhaps his final Olympic game and Spain added a bronze to its collection on Sunday with an 89-88 win over Australia, again denied its first medal inside the rings.

Sergio Rodriguez made two free throws with 5.4 seconds left and the Spaniards, who captured silver in 2008 at Beijing and the London Games, got the defensive stop they needed as Australia fumbled the ball away on its last possession.

Gasol, who will spend next season in San Antonio and hasn't committed to playing at Tokyo in 2020, and his teammates celebrated by piling on top of each other near center court. This wasn't the medal they wanted, but after losing their first two games in Brazil, it beats nothing.

"Unbelievable," said Rudy Fernandez. "It's an amazing feeling. We played very bad at first in the tournament, but we just continued to play hard and with a medal, it's unbelievable."

For the Aussies, it's more Olympic heartbreak. Several Australian players broke down crying after the country's fourth fourth-place finish, and this one was particularly cruel.

Patty Mills scored 30 and David Andersen 15 for the Aussies, who played almost the entire second half without Andrew Bogut. The 7-footer fouled out less than two minutes into the third quarter and spent the second half watching and worrying.

"There's no real positive you can take from this," Mills said. "For other people, yeah, the top four is great. We're disappointed not being able to make history for our country."

Australia's Aron Baynes dropped a hook shot in the lane — the ball rattling around before dropping — to give the Aussies an 88-87 lead with 9.7 seconds left.

Following a timeout, Rodriguez drove the right side and flipped up a layup as he stumbled near the basket. The shot missed, but Mills was called for a block despite little contact. A two-time Olympian, Rodriguez, who recently signed with the Philadelphia 76ers, dropped both free throws to make it 89-88.

The Aussies inbounded the ball and tried to run a screen for Mills, their captain who had brought them closer together with a trip to his Aboriginal homeland last summer, couldn't get free and the ball was knocked away from Andersen.

When it rolled into the backcourt and the clock expired, the Spaniards, who were unable to beat the U.S. in three straight Olympics, stormed the court.

The Aussies simply lowered their heads. Another close call. Another disappointment.

As upset as he was at losing, Bogut was equally angry about the officiating.

"They fall over and get fouls and go to the free throw line the whole game," he said. "It's unbelievable. You just dive into guys recklessly and get calls like that. It's tough to play like that."

With an internationally experienced roster featuring five NBA players, four of whom won league titles, Australia came to Brazil with a team capable of finally ending their country's Olympic medal drought.

With Bogut back from a knee injury sustained in the NBA Finals, they were arguably the sharpest team in the preliminary round, sending a tremor through the tournament by staying within 10 points of a U.S. team that appeared to have some cracks.

But with a chance to secure their first medal, the Aussies flopped in the semifinals against Serbia. They couldn't make a shot and lost by 26.

They went back and forth with Spain for four quarters, but will leave Rio empty-handed.

For the 36-year-old Gasol, this bronze is almost as good as gold.

He played in these games without his brother, Marc, who is still recovering from a foot injury. And although he wants to continue with the national team, Gasol said he'll go year to year.

No one has meant more to Spain's program and it was clear from the start he wanted any medal.

In the first half, he dived headfirst to save a ball going out of bounds, and his teammates erupted at seeing his sacrifice. He battled Andersen inside, the two players exchanging shoves and dirty looks as each team tried but couldn't shake free from the other.

"He's amazing," Rubio said. "There's no words to describe the way he dominates FIBA basketball. He's one of the best ever. That's why he put Spain on the map. We have great players around him, but he's the key of this generation."

The one with another medal.