Updated

On the last performance show of season 8 of “Dancing With the Stars,” gymnast Shawn Johnson overturned many people’s expectations by tying with actor Gilles Marini for first place with a total judges’ score of 58 for two performances. “Bachelor” star Melissa Rycroft came in third with a score of 56.

This is the first time that Shawn has come in first this season since week 3, when she tied with Gilles and Melissa. Gilles has now finished in first place eight times and Melissa three.

Each of the three remaining stars and their partners performed two dances last night, a group paso doble and an individual freestyle dance (lifts allowed!). Before the group dance, we saw Len Goodman talking on the phone in his limousine with the DANCMSTR vanity plates. He told Bruno Tonioli (who was shown poolside in a Speedo and an unnatural-looking tan) and Carrie Ann Inaba (eating a salad at an outdoor table) to go train the contestants in the paso.

Now fully dressed, Bruno advised Shawn and her partner, Mark Ballas, that they had to surprise the audience with something they’d never done before. “Bruno helped me take my paso over the top,” Shawn told the camera.

“Melissa has a tendency to revert to her ballet and cheerleader background,” Carrie Ann said. She gave Melissa lessons in how to intimidate people and make them move off the dance floor.

PHOTOS: Click here to see photos of the cast.

Finally, Len told Gilles to make this paso doble less hectic than his last one. More important, Len told Gilles and his partner, Cheryl Burke, that they had made him do something he thought he’d never do again in a rehearsal space: “You made me perspire!”

Dancing to Pink’s “So What,” the three couples basically took turns performing three individual paso dobles. Shawn, keeping a poker face throughout, danced precisely and cleanly, her sharp extensions helping to overcome her lack of height. Melissa had a little trip-up at one point and overdid the kicks. (Her long legs were showcased in her classic “DWTS” costume: a bikini that wasn’t covered by an open “Matrix”/dominatrix overcoat.) Gilles may have had an advantage being the only man still in the competition, as the paso calls for the male partner to be especially dominant. He strode about exuding the requisite Latin arrogance.

Len told Shawn her performance was full of excitement, although he called her on lowering her chin occasionally. He said Melissa’s routine was far more convincing than her last paso despite the slight mistake. And he said Gilles had “intensity” and was great.

Bruno praised all the couples for both competing and working together as a team. He said that Shawn is always strong and a great technician, and he called Melissa a drama queen and Gilles a leading man (both in a good way).

Saying that this has been her favorite season, Carrie Ann said that all of the stars were “incredible dancers” but that watching them side by side highlighted their weaknesses and strengths. Shawn, she said, was “perfection” but lacked an emotional connection, while Melissa had managed to find that emotional connection this time. From Gilles, she said, “I always expect perfection in a Latin dance, and there it was.”

Shawn received a 9 from Carrie Ann, a 9 from Len, and a 10 from Bruno (with an especially emphatic fist pump because he was disagreeing with both of the other judges). Melissa received a 10 from Carrie Ann, a 9 from Len, and a 10 from Bruno (with an odd hand flip). (She and her partner, Tony Dovolani, both got kisses from Gilles as well.) Gilles got straight 10’s (again with that odd hand flip from Bruno).

(Although this isn’t that significant given that six of the nine scores on the paso doble were 10’s, each of the judges did give a 10 to the couple he or she coached.)

The freestyle round kicked off with footage of Shawn being visited by Apolo Anton Ohno, a fellow Olympic athlete and the season 4 winner of “DWTS.” He reminded her that every other Olympian who has made it to the finals (that would be Kristi Yamaguchi) has won.

Nonetheless, Shawn said she would not be using gymnastics in the routine “because we got in trouble last time.” It looked like real trouble when she and Mark showed up on the edge of the dance floor wearing sequined masks, black leather shirts and trousers and white gloves, signaling that they were about to launch into some sort of mimed.

Fortunately, when they began dancing, to the Basement Jaxx’s “Do Your Thing,” they tore off the masks and the shirts (revealing a key-lime-green bikini top on her and a matching jacket on him. The routine combined lots of sharp moves, athletic lifts, floor work and jazz hands. As usual, Shawn hit every beat perfectly. Her final split, however, was pretty gymnastic.

“I’m telling you one thing, kid,” said Bruno, standing up and yelling to be heard over the audience’s lengthy applause. “You’re going for gold.” Carrie Ann said Shawn was “so adorable.” Len basically said he loved everything about it.

“This is like my new gold medal,” said Shawn to co-host Samantha Harris backstage. She received perfect 10’s (with the fist pump), although that jokester Bruno said he was giving an 11.

Adding an ominous note to the rehearsal footage of Melissa and Tony, the producers showed footage of him failing to win the last time he was in the finals, in season 2 with the leggy Stacy Keibler. Tony said he had learned that you have to go for it and do tricks. “There’s always danger in tricks,” said Melissa, and sure enough, she wound up banging him in the eye. “You’re breaking my ribs, I’m breaking your eye,” she told him.

Melissa and Tony were wearing hip-hoppy outfits at the start of their routine, but as soon as C+C Music Factory’s “Gonna Make You Sweat” kicked in, Melissa ripped off her baggy T-shirt to reveal another bikini top. (Tony was wearing a see-through shirt that prompted host Tom Bergeron to say, “You’ve gotta give them points for the creative use of mosquito netting.”)

Melissa seemed a little hesitant throughout, pausing before their big stunts and falling out of step with Tony when they weren’t touching. Both Carrie Ann and Bruno thought the choreography seemed disjointed. (“I thought I’d never live to see the running man again,” added Bruno, pumping his arms.) Len said that he was disappointed that Melissa hadn’t chosen to show her elegant side. The judges gave her straight 9’s, which in a regular week is good but in the finals, when a 9 is basically the lowest score possible, could be the kiss of death.

Teasing Gilles’ rehearsal footage, Tom said, “Last week, he had Len giving him a sitting-down standing ovation and wishing that his paddle went to 11, and what guy hasn’t said that?” Then we saw the judges giving two sets of perfect scores. “I feel like the underdog,” said Gilles, whose constant self-deprecation may backfire on him eventually.

Cheryl told Gilles the lessons she’d learning winning “DWTS” back in seasons 2 and 3 and then said that he had the potential to be even better than her partners those years, Drew Lachey and Emmitt Smith. Unfortunately, Gilles’ shoulder acted up, and he got a visit from a pain specialist rather than either of them.

At the start of Gilles and Cheryl’s routine, set to the theme from “Flashdance,” they took turns sitting in a chair, but disappointingly, neither one was doused with water. Wearing legwarmers (she probably wouldn’t have dared if Edyta Sliwinska were still around), Cheryl did a few moves from the movie and basically cut loose. Unfortunately, she drew attention away from Gilles, who may have been favoring his shoulder and came across as tentative.

Len said the performance proved that Gilles is a real dancer. Bruno said it was a great performance but that he expected more from Gilles. “It was an odd choice,” said Carrie Ann, pointing out that “Flashdance” is about a female dancer. Still, she told Gilles, “You were amazing.”

Backstage, Gilles gave a long thank-you speech, saying, “This experience, like, took me to a different planet.” (That pretty well sums up the “DWTS” experience for all of us, doesn’t it?) Carrie Ann and Bruno gave him a 9; Len, probably because the performance was a notch above Melissa’s though far from perfect, gave him a 10.

So here’s how the stars lined up on the judges’ leaderboard:

Shawn Johnson and Mark Ballas: 58 (28 for the group paso doble, 30 for freestyle)
Gilles Marini and Cheryl Burke: 58 (30, 28)
Melissa Rycroft and Tony Dovolani: 56 (29, 27)

Gilles seems the likely winner in Tuesday night’s finale, especially after Tom mentioned that if you add up the judges’ votes for the whole season, Gilles has a 17 point lead over the others, who are separated by only one point. It’s difficult to estimate the viewers’ support, however, and the judges are still going to weigh in on Tuesday with one final vote.

Whatever happens, that close-up shot of the mirror-ball trophy made it all seem worthwhile.