Check the posts on both sides of your gate with a level to make sure they are plumb. To adjust gate side posts, use the gate as leverage and shift the post into its proper position. Brace the gate with scrap lumber to keep the post into the right position.
Dig out around whichever side of the post that it was sagging toward. Remove dirt 6 inches out from the post all the way to the post's bottom.
Fill the area you removed the dirt from with dry concrete mix up to two inches below ground level. Add enough water to mix the concrete. Mix with a scrap of lumber. Allow the concrete to harden for 24 hours before proceeding.
Reinforce the gate side post with heavy duty L brackets attached between the post and the horizontal rails on the fence panel. Tighten all gate hinge bolts in the gate and in the post.
Dig out around the latch side post in similar fashion if it is out of plumb and fill with concrete. Reinforce the post with L brackets as for the hinge side post.
Brace the gate with a cable and turnbuckle which can be purchased as a gate lift kit. There are two basic styles of cable lift; one with corner brackets and one with eye hooks. Lift kits vary in installation and instructions.
Drill a ¼-inch pilot hole in the hinge side top corner and one in the latch side bottom corner of the back of the fence panel if you are using a kit with eye bolts. Drive one eye bolt into each of the pilot holes. Attach one piece of cable to the eye bolt at one corner and one end of the turnbuckle. Attach the other piece to the opposite end of the turnbuckle and the eye bolt in the opposite corner.
Attach the brackets (for bracket styles) at the top of the hinge side and at the bottom of the latch side. Attach the cables to the brackets with the turnbuckle between them.
Use a pair of pliers or an adjustable spanner to turn the turnbuckle to tighten the cable. Tighten all hardware bolts in both gate and post latch pieces. Close the gate and test the latch. Adjust by turning the cable to raise or lower the gate as needed until the latch operates smoothly.