To be fair, the territories were not Pepin's to give, not originally anyway. They were under control of Aistulf, king of the Lombards. A few years earlier, in 751, Aistulf conquered the exarchate of Ravenna. The exarchate of Ravenna was the last piece of Italy considered to be part of the Roman Empire, having been established by Byzantine Emperor Justinian as part of his plan to administer the western part of the fading empire.
Aistulf decided that his conquest of Ravenna and killing of the last ruler of it, the exarch Eutychius, meant he was now the nearest thing to a Roman Emperor. He therefore demanded that Rome itself submit to him and send him a tribute of one gold solidus per person.
Pope Stephen II could not negotiate with Aistulf to back down, so he sent a request to Pepin to come to his aid. The Franks and Lombards were on friendly terms, so Stephen thought Pepin would have better luck. Pepin promised the pope he would arrange the return of the Exarchate of Ravenna. The pope in return anointed Pepin and his sons Charles (Charlemagne) and Carloman as kings of the Franks (they did not need this to be kings, but it was a nice piece of recognition from a figure who was seen as the head of the Christian faith). He also named them patricians of the Romans, an honorary title suggesting they were Roman elite. The pope also pronounced a blessing on Pepin's wife, Bertrada.
So Pepin took his army to Lombardy, surrounded Aistulf's forces, defeated any military opposition, and made Aistulf promise to return Ravenna. A treaty was signed, Pepin turned around to go home, and once he had left Lombardy, Aistulf ignored the treaty. Aistulf besieged Rome. Word went to Pepin. The Frankish army came and forced Aistulf to abandon the siege.
So more than Ravenna became part of the Papal states, because Pepin turned over Lombardy as well and several other cities. Emissaries of the Roman Empire entreated Pepin to give the land to the political empire, not the spiritual papacy, but Pepin would not. The pope would now be a temporal ruler for centuries to come.
You may have heard that there was an earlier gift of land to the pope, called the Donation of Constantine. We will talk about this hoax tomorrow.