This one went as scripted. When the final rotation turned, it put a bow on a 7-under-par 65 in the final round of the 3M Championship on Sunday, giving the 53-year-old Perry a 23-under total he thought would be plenty for his seventh Champions Tour victory.

It wound up being just enough, because Bernhard Langer had a different ending in mind.

“Talk about a bubble deflation,” said Perry, who was 6 under through 11 holes, then made six straight pars. “I’m thinking this deal’s over. I didn’t see a scoreboard until 17.”

Playing one group ahead and trailing Perry by three shots to start the day, Langer clawed his way into a tie at 22 under heading to the par-5 18th.

Then the golf gods took over.

Langer’s drive came to rest on a sprinkler head mound in the fairway, leaving him with an uneven lie. He struck the approach shot awkwardly, causing the ball to land in tall, thick grass in front of the green. He was fortunate to save par after a tricky chip that forced him to have one foot on grass and the other on a landscape boulder.

“Not my normal stance,” Langer deadpanned.

That was lucky for Perry, who got away with a poor drive when he bombed his second shot from 225 yards away. The ball landed under the grandstand behind the cavernous green.

“That’s the shot, off the green monster back there,” said Perry, who won $262,500 with the victory. “It was a beautiful shot, but it didn’t carom back.”

A free drop set up the harder-than-he-thought victory over Langer, the Schwab Cup points leader.

Perry will hope to use the momentum this week when he competes on a special exemption into the PGA Championship at Valhalla in his home state of Kentucky.

For Langer, it’s a feeling of disappointment despite finishing the day 9 under.

“My goal was to shoot 8 under, thinking 21 under should have a chance to win,” Langer said. “I outdid myself and still didn’t win. It just proves how good the players are out here. What Kenny did this week was pretty exceptional. Certainly amazing golf.”

The final scoring average for the tournament was 69.609, the lowest in the 22-year history of the event.

Perry and Langer were the last two standing on a weekend bleeding with red numbers. Jeff Maggert, Gene Sauers and Marco Dawson all finished tied for third at 20 under.

Paul Goydos, making his Champions Tour debut at TPC Twin Cities, remarked before the start of the traditionally low-scoring tournament, “I didn’t see 16, 20 under par” following a practice round.

But the galleries were treated to birdie after birdie. Eight players completed the tournament 16 under or better. Goydos finished in a six-way tie for ninth at 14 under, a group that included Hale Irwin and Wes Short Jr.

Irwin, 69, bettered his age in all three rounds of the tournament and finished in the top 10 for the second time in four years.

Short shot the round of the tournament Sunday with a 10-under 62, one shy of the 3M record set in 2010 by David Frost.

Langer, 56, was denied a third 3M Championship title one week after coasting to a 13-shot victory at the Senior British Open in Wales.

Even without the victory, Langer continues his run of dominance on the Champions Tour. He has finished in the top 10 in 28 of his past 30 starts, including the Masters.

“The competition is great out here but he’s like a robot,” said Sauers, one of Langer’s playing partners Sunday. “As long as I can stay near him, I’ll be fine.”

Langer stood on a hill beside the 18th green watching Perry’s last two shots, munching on a banana for added energy should there be a playoff.