Keglević was captain from 1521 to 1522 and later ban of Jajce. In 1526, some months before the Battle of Mohács, he got the jus gladii, even though he did not take part in the battle. In he becomes one of the captains and chief officers of the royal Hussars. From 25 May 1533 to 9 December 1537, he was the royal commissary for Croatia and Slavonia as attorney general. From 1537 to 1542, he was the ban of Croatia and Slavonia. The Battle of Mohács was very traumatic. The history of the persons who were relevant after that - among them also Petar Keglević - is described again and again. A part of Zagreb is still named after him. He distinguished himself in battles against the Ottoman Empire and he achieved a special agreement. After the battle of Mohács, he sided with Emperor Ferdinand against János Szapolyai. Zápolya had made a Franco-Hungarian alliance. Petar Keglević made a special agreement with the Ottoman Empire. The result was a Franco-Ottoman alliance and as an unintended consequence moved Jeronimo Bassano from Venice to England. This architecture of Europe should be kept for centuries. He increased his family's holdings through purchases and royal gifts. After the death of Keglević's son-in-law Caspar Ernuszt, he assumed ownership of his possessions in Međimurje. In 1542, he was sentenced as an infidel by the Diet in Pressburg, because of his special agreement with the Ottoman Empire and because of the unlawful ownership of Međimurje. Emperor Ferdinand removed him from his position as ban and confiscated his properties in 1542. One of the sons of Petar Keglević moved to Valladolid and Mehmed-paša Sokolović became Commander of the Imperial Squires and later Grand Vizier. Emperor Ferdinand imprisoned Keglević in 1546 in house arrest in one of his own houses of his own choice. In 1548 he was granted an amnesty and was returned all of his goods along with his grandfather's Bužim. In the year 1552 Emperor Ferdinand visited him as a private person and brought him news from Valladolid. He was not involved in the dynastic fight between the Habsburgs and the Jagiellonians, although he made the business with George, Margrave of Brandenburg-Ansbach, so that this one pulled back from Hungary and Croatia. Petar Keglević was married to Barbara Strezsemley from Streza, from family Bissenus de Streza. Streza was the uncle of king Dmitar Zvonimir. Streza descended from Bissenus de genere Aba, who was a descendant of the Hungarian king Samuel Aba, a grandson of Géza, Grand Prince of the Hungarians. Count Péter VII Keglevich is his descendant. He died in 1554 or 1555.