Petra is first referred to in the Novellae Constitutiones by the Eastern Roman emperor Justinian I, dated to 535. It was built to reinforce the Roman authority in the kingdom of Lazica, located on the southeastern shores of the Black Sea and, with the emperor's approval, was named in his honor as Petra Pia Justiniana. According to the contemporary historian Procopius, Petra was founded through the efforts of the Roman official John Tzibus, who thereafter exercised tight control of imports into Lazica and controlled local access to luxury commodities and much-needed salt. The name of Petra, literally, "rock" in Greek, was a reference to the rocky and precipitous coast where the city was built. Its location between the sea and the cliffs rendered the city inaccessible, except for a narrow and rocky stretch of level ground, which was defended by a defensive wall with two towers.
Tzibus' monopolization of trade in Petra soured Rome's relations with the Lazi, whose king, Gubazes, secretly sought Sasanian assistance against Rome. This occasioned an invasion by a Sasanian army under Khosrow I in 541 and twenty years of war in Lazica, in the course of which Petra changed hands several times. In 541, Khosrow, following an initial unsuccessful assault on the fortifications of the city, captured Petra by sending his troops through a secretly constructed tunnel and destroying the towers, which induced the Romans to capitulate. Khosrow appropriated the riches of Tzibus, who was killed in battle, but treated the Romans of the city with consideration.
In 548, Justinian sent a force under Dagisthaeus—this time allied with the Lazi, who had become discontent with Sasanian hegemony—to retake Petra. The allies besieged the city and defeated two Sasanian field armies sent to its aid, but subsequent maneuvers by the Iranian commander Mihr-Mihroe made the besiegers' positions untenable. Eventually, Dagisthaeus failed to retake Petra and withdrew in 549. In 551, a Roman–Lazi army under Bessas began a second siege. After prolonged fighting, the city fell and Bessas razed the city fortress to the ground to prevent it again becoming a Sasanian target.