Some Yankees fans waited hours — some didn’t wait at all. And through the chaos, the Yankees defended the way they handled the mess.

Tuesday night’s Mariano Rivera bobblehead giveaway turned into a nightmare when the figurines didn’t arrive before the game because of a delivery problem, forcing the Yankees to hand out vouchers, which were redeemable after the third inning, to the first 18,000 fans.

Thousands of fans — at least those who had to wait — stood in line for more than an hour and many were still in line after the game. Fans in the priciest seats at the Stadium had their bobbleheads brought to them by team personnel, witnesses said.

“It’s a disgrace that this is how the Yankees treat their fans,” said Dennis Houston of Queens, who had been waiting nearly an hour and still had not gotten his figurine after the game.

“The players will be home in bed before I get my bobblehead,” said Regina Palmieri of Yorktown Heights, who was still waiting after the last out of the Yankees’ 7-0 debacle against the Rays that left them on the brink of elimination from the playoff race.

Lines wound throughout the Stadium all night, some fans getting on line on the lower level, heading to the upper deck and then back downstairs to get their bobbleheads.

One fan claimed on Twitter that he got on line in the fourth inning and was still on line in the ninth inning.

“It’s a testament to so many people in the organization that we accomplished what we did,” said Yankees’ media relations director Jason Zillo, “given the hand that we were dealt.”

Zillo said he was unaware that at least some fans in the most expensive seats had their vouchers redeemed for them by Stadium employees.

The shipment of 850 boxes from Seattle to New Jersey was delayed Monday night when the train carrying the dolls had mechanical issues in Chicago.

The boxes still reached their destination in New Jersey in time to get to The Bronx on schedule, but the truck delivering them had a hydraulic problem, and they didn’t make it to The Stadium until after 6 p.m.

So the first 18,000 fans received vouchers and were told to pick up the dolls starting in the third inning. That’s when the lines and aggravation started.

“I’m ticked off,” said Evan (E.K.) Hernandez of the Upper West Side. “I came to see a game, not stand on line.”

Vinnie Luca, a barber from North Babylon, did it for his kids.

“It’s for my kids,” said Luca who waited an estimated 20 minutes after he “took off from work” so he’d be of the first to arrive. “Believe me, I wouldn’t be here if it wasn’t for them.”

Luca had four vouchers. “Two they can play with and two I’ll put away to pay for college,” he said with a smile.

But others weren’t smiling.

“Annoying,” said Angel Bury of the Bronx. “Really annoying.”

As the line grew, so did tales of the length of the wait. Some basically claimed to have been lined up since Mantle and Maris roamed the outfield.

“I got here at 4:30. I’m missing so much of the game already. I didn’t want to be on a line,” said Ron Santorelli of Yorktown Heights.

Jeff Pynn of Putnam Valley said he began his wait on a lower level and then moved upstairs — only to come back down.

“It’s crazy,” Pynn said. “Down, up, then down again. Absolutely crazy.”