STANDING on the stage of the Mariinsky Theatre in St Petersburg, I can feel cultural ghosts winding around me. Nureyev and Nijinsky limber up in the wings; Anna Pavlova totters past on tiptoe, performing The Dying Swan; out in the auditorium, Tchaikovsky accepts the applause that greets the premiere of his opera, The Queen Of Spades. I breathe in the history of the building, my eyes rising past five levels of gilded boxes to the ornate painted ceiling and soft light of the chandeliers. And then a cleaner knocks her mop against her bucket, a prosaic reminder that this is not a museum but a working theatre. Tonight, and every night, the show must go on.

St Petersburg, Petrograd, Leningrad ... Call it what you will, but this has always been the most European of Russian cities. Peter the Great's "window on the West" has survived the decadence of the tsars, the fervour of the Bolsheviks and wartime siege by the Nazis. Now it is resurgent in a tourist-driven, post-Soviet, capitalist-savvy era.

All of which makes it an appropriate location for the Russian premiere of a new production of Karol Szymanowski's 1926 opera King Roger. A key work by a Polish composer, performed by Russia's most prestigious opera company, soon to be a centrepiece of this year's Edinburgh International Festival (EIF), King Roger is internationalist in its very essence. If EIF director Jonathan Mills needed one single piece to illustrate the "Artists Without Borders" concept embedded within his 2008 programme, then King Roger is it.

As the warning bell rings and the lights dim in the theatre, there is a buzz of anticipation that seems special even for a new work in the Stars Of The White Nights festival programme, the three-month-long cultural buffet that nourishes St Petersburg's long summer nights. The majority of the chorus and orchestra is Russian, but the principal singers are Polish. How will the audience react to this breaching of their artistic borders?

The first thing to note is that the production's Polish director, Mariusz Trelinski, has abandoned Szymanowski's 12th-century trappings in favour of modern costumes and design. Instead of the culture-clash disruption of a Christian king's Sicilian court by the god Dionysus disguised as a shepherd, with scenes set in Palmero Cathedral and an ancient Greek temple, we open on the slate-grey interior of a contemporary church. King Roger (Andrzej Dobber) is dressed in a long black coat, wearing sunglasses to intimidate his subjects. When the bleached-blond Shepherd (Pavlo Tolstoy) arrives, the king's thugs beat him up and kick him when he's down. For an audience who grew up under the KGB, this surely hits closer to home than any allegory about the transformative power of paganism on organised religion. Later acts bring a Bacchanalian orgy and a sequence of visual projections that reminds me of a Chemical Brothers live set or a scene from 2001: A Space Odyssey.

During one of the lengthy intervals, I drag Mills off to one of the Mariinsky's quieter corners to discuss the production and how it fits into his plans for Edinburgh. He is enthusiastic about the adventurous direction, believing that Trelinkski's approach has freed up the opera's "archetypal" elements.

"You can look at those people as former Polish prime minister and president General Jaruzelski," he says. "It could be Poland before Solidarity; it could be The Sopranos. It's about power relationships. And it gives the most fantastic breadth to the music."

Mills, who was appointed director of the EIF in October 2006, has found a musical soul-mate in conductor Valery Gergiev. The 45-year-old Australian has invited the 55-year-old native of the Ossetian Caucasus to take up what amounts to a residency in Edinburgh this August. Gergiev will conduct not only King Roger, but performances of Shchedrin's The Enchanted Wanderer, Rachmaninov's Aleko and the third act of Prokofiev's Semyon Kotko, as well as the same composer's cycle of seven symphonies and selected other orchestral works.

"I hope you hear King Roger again in Scotland, because Gergiev will build from this," Mills tells me. "He has absolutely got his house and now he'll decorate it."

Back in the Mariinsky's auditorium, I swap seats with a colleague and sit in the front row, directly behind Gergiev's podium in the orchestra pit. His left arm makes large sweeping gestures, encouraging swells of sound and diminishing whispers from the musicians. His right arm sticks out at 90 degrees from his body, turning sharply inwards at the elbow, the fluttering tremors of his fingers caressing the notes as his hand moves down through the air. It makes for a striking combination of physical strength and artistic sensitivity, the very elements that have seen Gergiev (as general director and artistic director) shake off the Mariinsky's Soviet legacy (when it was known to the wider world as the Kirov) and broaden its repertoire to become an international cultural force.

Hard-working and charismatic, with hooded eyes and designer stubble, it's easy to get swept up in Gergiev's wake. And, after the curtain falls on King Roger, I do. I'm asked to meet him on-stage after he has thanked the performers. It's still light outside, but the clock says it is approaching 11pm. I'm ready to slip off for a late dinner, but Gergiev issues a further invitation to come with him to a restaurant behind the theatre. The walls of this establishment are covered by the signatures of famous stars of opera and ballet. On a piano stands a photograph of a group containing Gergiev and Vladimir Putin; and it's not the Russian prime minister who dominates the frame.

As the wine and the vodka begin to flow, cast members cross the room to have their photograph taken with the maestro. Phrases of song flicker from table to table, as professional voices ready themselves for informal fun. They say it's not over until the fat lady sings. Looking around this young and fit ensemble, there's not a fat lady or gentleman among them. Appropriately, then, the party might go on for some time yet ...

The following day, I realise that there's another side to the maestro's generosity with his time. An interview has been promised, but I am continually bumped from his schedule as he squeezes in other commitments. On top of his many Mariinsky roles, he is artistic director of the White Nights Festival, principal conductor of the London Symphony Orchestra and principal guest conductor of the Metropolitan Opera in New York.

The interview is set for the hour before the Mariinsky Ballet takes over the stage with a triple bill of one-act works choreographed by George Balanchine. But Gergiev is locked in a meeting, and instead I'm taken on a backstage tour. Then we aim for the intervals, but Italian President Giorgio Napolitano has decided to visit, and Gergiev must be on hand for him. Finally, after a magnificent performance of Bizet's Symphony In C, I am ushered into Gergiev's office. I dive straight into asking about his perspective on Mills's "Artists Without Borders" theme.

"I did not ask Jonathan, What's your vision?'" Gergiev says, "but I sense that, as a composer and musician himself, he very much believes in the power of music. Today, Poland and Russia do not enjoy the best of times in terms of relationships for certain reasons - because of the Soviet past, because Poland is now leaning towards America and Nato, discussing a system of missiles which will protect maybe Europe, maybe America, and be based in Poland. But we're musicians. We're not talking about missiles here; we are talking about the beauty, power and communicative strength of music. Jonathan, being a relatively new artistic director, brings his own vision and, if he manages to put Polish and Russian artists together - and Polish and Russian organisations, which is more tricky - then that's already quite an achievement."

Mills's vision seems to embody something greater than an old-fashioned "cultural exchange" programme. In the new Europe, the arts can open up debate and cause audiences to think afresh. At the top end, it's a question of those with cultural power realising that they have a duty to use that power for social, perhaps political, effect. For Gergiev, this became a reality four years ago when Chechen separatists took hostages in a school in Beslan in the North Caucasus region of the Russian Federation. After a series of explosions and a gun battle with security forces, hundreds of civilians were killed, many of them children. Gergiev, because of his roots in this area, went on national television to appeal for calm.

"Well, I wouldn't talk to the people of Sri Lanka or Bangladesh if something terrible happened there because, basically, they hardly know me," he explains. "But in this city, nearly everyone knows me. It was such a huge tragedy I don't like to talk about this, it is a difficult thing even to think about. But someone had to do it. I myself went to the president of Russian TV, and in five minutes he stopped everything. He understood it was maybe one of the very few chances to do something really significant, so I was on the air in about 15, 20 minutes. It was not political; it was just human."

Mills wouldn't make claims for his 2008 festival programme to assume anything as weighty as this. And yet it's possible to imagine how juxtapositions of one performance against another can create, in the minds of the audience, a third entirely separate idea. What thoughts might be engendered by seeing the Palestinian National Theatre's production of Jidariyya a mere 24 hours after the Scottish Chamber Orchestra performs Handel's oratorio Israel In Egypt? Or by contrasting the rhythms of the Whirling Dervishes of Turkey with dance troupe Rosas's programme of works set to the music of Steve Reich?

"It's not that I believe in themes or not in themes," argues Mills. "My starting point in this is: what is a festival? What distinguishes a festival from something else? Historically they have often been rites of passage, rites of spring. Sociologically there have also been those moments where they act like a pressure valve for a society, particularly rigid societies in times of economic hardship.

"What is a festival today? I don't pretend to have the answers, but I'm looking for them. The narrative that we've created this year is one that I think is very relevant and very exciting because it's a personal response to the experience of living in Europe today. It's nearly 20 years since the Berlin Wall fell, and I think things are starting to unravel in a very interesting way. Internationalism needs to be taken face-on, very honestly, and I think you'll find that my festivals, over the next four years, are an attempt to interpret this question of internationalism in a different way."

The interval bell has rung again, and it's time to take our seats in the splendour of the Mariinsky. Somewhere in the building, Valery Gergiev is extricating himself from yet another meeting. He makes his way, amid applause, to the podium. There is music to be played and work to be done.

King Roger is at the Festival Theatre, Edinburgh, August 25 and 27 www.eif.co.uk