By John Hand
BBC News, Madison Square Garden, New York
Madonna has attacked the Republican campaign throughout her tour
Rap star Pharrell Williams has made a surprise appearance with Madonna in a New York date on her world tour.
Williams, who co-produced and sang on Madonna's Hard Candy album earlier this year, joined her on stage during her final song of the show - Give It 2 Me.
Madonna also continued her recent attacks on Republican vice-presidential nominee Sarah Palin.
Playing a screeching note on her guitar, she said: "This is the sound of Sarah Palin thinking."
After singing an a capella version of her 1989 hit Express Yourself, she told the crowd: "I'd like to express myself to Sarah Palin right now."
She also threw condoms into the crowd at Madison Square Garden, saying that they promoted safe sex as they had a picture of Mrs Palin on them.
The anti-Republican barbs came a few days after Madonna told another concert audience: "Sarah Palin can't come to my party. Sarah Palin can't come to my show. It's nothing personal."
Throughout the tour, which started in Cardiff on 23 August, Madonna had stoked political controversy with one video segment which splices an image of Republican presidential nominee John McCain among those of Adolf Hitler, Robert Mugabe and scenes of destruction and starving children.
A spokesman for Mr McCain's campaign has called Madonna's actions "outrageous, unacceptable and crudely divisive all at the same time".
Pharrell Williams has appeared on the Sticky and Sweet tour before, but only in video form.
During previous dates, he and Madonna's other recent collaborators - Justin Timberlake, Kanye West and Britney Spears - have "performed" in the show as lifesize images on moving video walls.
At the New York show - the 21st date on the four-month world tour - there was a more tender moment as Madonna dedicated a song to her eldest daughter Lourdes to mark her 12th birthday.
She performed You Must Love Me, which she originally sang when she starred in the 1996 movie adaptation of the hit musical Evita. Madonna told the crowd: "My beautiful Lola is 12 today but when I first sang this song she was growing inside me."