Step 1: Reinforce the Pants
Pin this to the back of your pants, over the area where the hole is.
Using thread that matches the pants (or highly contrasting thread if you prefer), stitch around the hole, avoiding the pins, then back and forth across the torn area. Use the sewing machine's reverse function, angling the line slightly each pass, so that each line of stitching is a millimeter or two apart. When you've done one direction, turn the pants 90 degrees and do a second pass. You should end up with some stitching that looks like cross-hatching, and the hole will hardly be visible any more. The last pictures show this but they are sadly blurry (my apologies).
Step 2: Stitch the Loop Back On
Stitch back and forth across the end of the loop a couple times. Then decrease the stitch length and increase the width until you have a thin, short, zig-zag stitch, and go back & forth a couple more times. Finish the stitching in the middle of the loop as the stitching is less likely to pull out there.
And that is it. The mend will likely outlast the remaining loops but of course you can re-do it as many times as you need.