This is a much easier job when tackled by two people. You should preorder the replacement window and check its size on arrival. Remove the old window and prepare the opening; you will usually be able to fix a window directly through the frame into the wall. Always install the new frame at the same depth in the wall as the one you have removed. Seal the frame after installation.
How you install a window depends on your wall type and window design. Always follow any specific instructions that come with the window you purchased. However, the general technique is always similar. If you need to put in a new window sill, attach this into the bottom of the frame before you install the window.
Place the window in the rough opening in the same position that the old window occupied. Drive wood shims beneath the sill or frame to get it level and tight against the header. Use a level to ensure that the frame is horizontally and vertically straight. Gently insert shims down either side of the frame to hold it in position, not so tightly that they distort the shape of the frame. Measure the distance diagonally between opposite corners, and make sure both measurements are the same. Adjust the shims if necessary.
Open the casements to provide access to the side of the frame. Drill pilot holes for 4-inch (100-mm) frame fasteners through the frame and into the wall below. Every 1 foot (300 mm) should be sufficient. Hammer the nails in until the plugs sit flush with the frame. Use a cordless drill-driver to screw them so that they countersink into the frame and hold it securely in position. Avoid over-tightening, as this can distort the frame. If possible, fix through the top of the frame, but in many cases this will be impossible because of the header. Fix the bottom edge of the frame if the sill and frame depth allow. Bottom fixings are not recommended by some window manufacturers.
Saw off or chisel away any protruding shims. Fill any large gaps around the frame with expanding foam. You will need to protect vinyl window frames with low-tack masking tape (blue painter’s tape) if they have no protective film because the foam may damage the finish. Once the foam is dry, trim it neatly using a utility knife. Apply a thin, neat line of cement (a fillet) around the joint with the wall to hide the foam. On wood-framed homes, use wooden moldings, or for vinyl windows use the cover strips supplied.
Create a final seal with a continuous bead of caulk around the edge of the window frame. Glaze windows where necessary.
Windows are an historically typical cause of air and water infiltration in a home. Not only can heat loss or heat gain to a conditioned home increase your energy bills, it can also be the source of slow water leaks that cause serious mold problems. After you secure your new window in place, seal around the perimeter of your window frame with a line of latex caulk. It's important to use latex and not silicone if you want to paint around the window. Silicone caulk is unpaintable.