Slice the prickly pears in half and scoop the pulp out of the skin. Place in a saucepan with the sugar and water.
Mash the fruit with a potato masher, combining with the water. Turn the heat to medium low and simmer until the sugar is dissolved and the mixture becomes syrupy, about 10 to 15 minutes.
Strain the syrup into a bowl or jar. Cool, then add lime juice and stir.
To make the margarita, pour the syrup, tequila, lime juice, and triple sec into a cocktail shaker filled with ice. Shake until chilled and frothy, about 15 seconds.
If desired, rim a rocks glass with salt. Pour the margarita into the glass to serve.