Avignon once was a small city in the south of France. But in 1303, this would change: After Philippe IV the Fair had been excommunicated by the pope Boniface VIII, he had the latter seized by his men, and forced him to go to Avignon. 1309, the pope's move to Avignon became permanent. In the following decades, the (mostly French) popes would reign from here.
At the Great Reform council of Geneva (1401-07) the church decided that the pope should return to Rome; but when Naples was completely subjugated by the Rum-Seljuks 1459-61, everyone feared that the Papal States would be attacked next. The helpless pope fled to Avignon. And indeed, 1466 the infamous Sacco di Roma happened.
Since noone expected the situation to change very soon, people took comfort at the old and new seat of the Papacy. 1514, the French regent François was crowned Holy Roman Emperor Franz I in Avignon.
Even after Florence first and Italy later gradually recovered Rome and the rest of Central Italy, the pope preferred to stay in Avignon, and so did the kings of France. After the anti-French War however, they couldn't maintain this position any more against the rest of Europe, and the popes returned to Rome.
Although the popes had lost a lot of power, and became a mere representative position after the council of Cork, they still had a lot of influence and prestige. For these reasons, in 1738 king François VI of France managed to smuggle pope Innocent from Rome back to Avignon. The Italian king protested, but couldn't change it.
Finally however, when France became a republic, and the French Republican Wars started, the pope fled from Avignon. First he went down the Rhone river to Corse, but later he would move his seat to Toledo, Spain, since Italy didn't want to enter the war.