China has a love-hate relationship with what is foreign. Traditionally all people beyond the Great Wall were barbarians - only part human. But invaders have sometimes been welcomed, in time, into the Chinese family. One was Kublai Khan.

In the 13th Century, no-one knew how big the world was so it was not so wild for the Mongols to set off from the grassland with the idea that they were going to conquer all of it.

When the mighty Genghis Khan died in 1227, he had already claimed an empire stretching from the Pacific to Europe. His grandson Kublai set out to finish the job, and started by moving south to attack China's Song dynasty.

But China had been a united empire on and off for more than 1,000 years. So what did the Song dynasty rulers make of Kublai's ambition?

"For the Song, it would been absolutely inconceivable that the Mongols could take over the whole of China," says John Man, author of a biography of Kublai Khan.

"It would have been like, I don't know, the Picts taking over the Roman Empire or the Sioux in North America taking over the whole of Canada and the United States - inconceivable. So when it actually happened, the shock was catastrophic."

The child emperor committed suicide. So did many loyal officials and their families.

Over centuries, the Chinese had got used to regarding themselves as THE world civilisation, and now this civilisation was at the mercy of people they viewed as barbarians.

"Barbarians are these people who are not Chinese - savages, hovering between human and some kind of beast," says Xun Zhou, a historian at Hong Kong University.

As History is My Witness Former BBC Beijing correspondent Carrie Gracie presents a 10-part series on figures from Chinese history who reveal something about China

Programmes can be heard every weekday on BBC Radio 4 at 13:45 BST

Alternatively, listen again on the BBC iPlayer China: As History Is My Witness Download the podcast

She points out that unease about the barbarian or foreign devil is embedded in Chinese writing. Part of the character used to refer to them is the one used for animals.

"These people looked different. And that difference proposed a problem," says Xun Zhou. "For China, they don't really know how they should react to these people."

Mongol pleasures included wrestling, fermented mare's milk and throat singing, where the singer sings chords instead of single notes.

All very different from the southern Chinese elites who wore exquisite silks, admired each other's poetry and went to art exhibitions. They paid armies to do the fighting.

Kublai was hugely outnumbered. The Song dynasty was a "a monumental culture" of 70 million people, says Man, and 10 to 100 times stronger in military terms.

The Mongols had to be clever. One major battle took place at Xiangyang, a city with impenetrable walls dominating the Han River, a tributary of the Yangtze.

Having a porous sense of what is Chinese is itself part of the Chinese tradition

"This turned into a sort of a mini Troy," says Man.

"The siege went on for five years. The Chinese could not break out, the Mongols could not break in. There were countless attempts to sneak in, to break in, to break out - all foiled. So there had to be some sort of a new initiative, and the initiative was suggested by the empire itself."

The Mongol empire, that is.

Kublai's relatives ruled all the way to Eastern Europe and he had heard of great catapults the Christians had used during the Crusades. He summoned two Persian engineers, who built the equivalent of heavy artillery - a catapult that could sling 100kg (220lb) of rock over 200m-300m (650ft - 1,000ft).

After a few shots to get the range, it brought down a mighty tower in a cloud of dust. The capture of the city allowed the Mongol fleets access to southern China which, for the first time, was taken by barbarians.

Kublai, in fact, ruled over all of present-day China. Yunnan in the south-west bordering Vietnam and Burma, Xinjiang stretching into central Asia, and of course Tibet. It is paradoxical that the country owes its enormous size to invaders with expansionist ambitions.

Kublai Khan's pleasure dome The Venetian merchant Marco Polo left a description of Kublai Khan's palace which, slightly shortened, goes like this: "It is enclosed all round by a great wall with five gates on its southern face, the middle one never opened on any occasion except when the Khan himself goes forth or enters. This is the greatest palace that ever was. The roof is very lofty, and the walls of the palace are all covered with gold and silver. The hall is so large that it could easily dine 6,000 people. The roof is vermilion, yellow, green and blue, the tiles fixed with a varnish so fine that they shine like crystal and can be seen from a great distance."

Kublai's capital was Beijing. The city today goes on putting up scaffolding and high-rises. But it was Kublai who gave it its first big makeover.

He gave his dynasty a Chinese name, Yuan, and he ruled through a Chinese civil service. Chinese history has returned the compliment by absorbing the Mongol dynasty into its own imperial story - and absorbing part of Mongolia itself into the Chinese state.

Today the Mongolians form one of China's 56 ethnic groups, along with Tibetans, Uighurs and the dominant Han.

Having a porous sense of what is Chinese is itself part of the Chinese tradition.

The same applies to innovations the barbarians brought with them and which China found useful. Chinese medicine absorbed Islamic medicine, points out Xun, "but they never talk about it".

Galloping as they did from one end of Eurasia to the other, the Mongols had picked up plenty of useful novelties.

"They introduced buttons," says Verity Wilson, an expert on Chinese clothes and textiles.

"Prior to this time, men and women had always closed their robes with some sort of belt. But, the Yuan dynasty is credited with bringing to China the toggle-and-loop button, which now today we just call Chinese. It's a real marker of Chinese dress that they're closed with these toggle-and-loop buttons. But they didn't really come in until the Yuan dynasty."

This process of assimilation has continued ever since. Chillies are a later example, arriving from the New World in the Ming dynasty of the 15th and 16th centuries.

"But now they've been absolutely incorporated into the Chinese way of life, and we can't really think about Chinese cooking without chillies," says Wilson.

"And the other thing we think about is teapots. Teapots have very much become an item associated with China. But pre-Ming dynasty, there were no teapots in China. So I think all those things which we take to be quintessentially Chinese have actually been absorbed by the Chinese from other cultures."

The arrival of the bicycle some 500 years later was initially greeted with scorn.

To begin with, it was only so-called "foreign devils" who rode them. No self-respecting Chinese gentleman - and even less a woman - would be seen sweating under their own locomotion. But soon it would become the Chinese worker's vehicle of choice.

Just 50 years ago, if a Chinese had declared a preference for American food, it might have cost them their liberty, if not their life. China rid itself of Japanese occupation at the end of World War II and the communists had thrown out Westerners after 1949. Soon, even the Soviets were sent packing.

It was part of the party's narrative of a united China standing up to foreign aggressors.

But by the 1980s, foreigners were being welcomed back. Which is why, 20 years ago, I attended the opening of the first McDonald's restaurant in Beijing. Now it feels as if there is American fast food or coffee on every corner.

Image caption McDonalds has more than 1,400 restaurants in China

In some ways, today's penetration of foreign products - American fast food, German cars and Japanese electronics - mirrors that of a century ago when the colonial powers had forced open Chinese ports to trade. The difference is that this time it is at China's invitation.

Columbus heads for China History throws up some very strange ironies. If it was not for Kublai Khan, the Western powers might never have got to China by the 19th Century. It was his legend which inspired the European age of exploration. "Because of Marco Polo's account of Kublai Khan, Columbus decided to head to China," says John Man. "He headed west and discovered that China was not where he thought it was, that America was in the way and so in the end it was Kublai through Marco Polo that inspired Columbus to discover America."

Kublai's own dream of world domination would never be realised. Twice he launched an armada against Japan, the largest the world had ever seen or would ever see again until the Allied invasion of Europe 700 years later. And twice his navy was scattered by what the Japanese called their kamikaze, or "divine wind".

The Mongol dream of world conquest sank with Kublai's ships.

"He became old, he became fat, he became ill. His only son and heir died, his wife died, and he himself died in 1294 and left this part of the empire to his heirs, and none of them matched him in competence," says Man.

"So 80 years later, they were chased out in a revolution and went back to the grassland from which they originally emerged."

The revolution put a home-grown emperor on the throne, but only until the next foreign dynasty which again brought China new territory and ideas.

The very last emperor of all loved bicycles, by the way. He is said to have removed doorstops in the Forbidden City so that he could cycle around, but that is another story. The point I want to make is that there is complicated history around what is Chinese… and what is not.

Translation of The Travels of Marco Polo by Colonel Sir Henry Yule.