If it were mine, I’d avoid trying to pry the whole frame out at once. From your photos, it looks like the frame is mechanically attached to the masonry and there may also be mortar/grout around parts of it, so I’d remove it in sections.
Before cutting anything, I’d first make sure this isn’t a structural frame supporting anything above it. If it’s an old door/window opening and there’s any doubt, I’d confirm that before removing the jamb.
Assuming it’s just a non-structural frame, my approach would be:
- Expose the attachment points. Scrape or chip away loose mortar around the frame so you can see whether it’s held by masonry anchors, screws, tabs, or just packed into the opening.
- Remove any accessible fasteners first. If there are screws or anchors that can be removed without damaging the surrounding masonry, take those out before cutting.
- Cut the frame into manageable sections. Rather than fighting the entire frame, make a couple of relief cuts through the metal with an angle grinder or reciprocating saw with a metal-cutting blade. Smaller sections are much easier to control.
- Protect the masonry while cutting. I’d keep the cuts as close to the metal as practical and avoid using a sledgehammer directly against the brick/block. A cold chisel and small hammer are much more controllable for separating mortar or freeing an edge.
- Work around the perimeter. Once one section is loose, use it to see where the remaining attachment points are. That is usually safer than applying a lot of force and discovering that one hidden anchor is still holding everything.
- Deal with the remaining anchors separately. If an anchor is embedded in the masonry and won't come out cleanly, cutting it flush is often preferable to trying to pull it out and taking a chunk of brick or block with it. You can then patch the small recess afterward.
- Clean up before installing the replacement. Remove loose mortar, rust scale, and debris, then check that the opening is reasonably sound and square before fitting the new frame.
I'd also wear eye/face protection when cutting the old metal, because rusted frames can break unpredictably and grinding masonry/metal creates a lot of dust and debris.
The main thing I'd avoid is the “bigger hammer” approach. If the frame is stubborn, there's usually still an attachment point holding it somewhere. Finding that point and cutting/removing it is much less likely to damage the surrounding masonry.