Cut through the paint between the interior trim and the sash stops on either side of the window and along the top edge. Insert a putty knife between the two pieces and wiggle it around to widen the gap. Put a pry bar into the gap and use it to pull the sash stops off the window frame.
Remove the old window's upper and lower sash by pulling the sashes' bottom edge out toward you. Insert a pry bar between the window trim and the wall. Use the pry bar to pull the trim forward and off the wall. Go outside and do the same with the exterior window trim. There may be screws securing this trim in place. If so, back them out and pull the trim off.
Insert a pry bar between the rough opening's sides and the jamb liners left in the opening. Pull the jamb liners forward and out of the opening. Grasp the strip running down the rough opening's top surface with pliers and pull it off.
Place a tube of silicone sealant into a caulk gun and cut off the tip. Run a bead of sealant along the rough opening's two bottom corners. Apply aluminum weather-proofing tape across the rough opening's bottom surface and about 6 inches up the sides.
Run a bead of silicone sealant along the corner where the rough opening's stops meet the rough opening. The stops are found on both sides and along the top. Apply a bead of sealant along the rough opening's window stoop, on the bottom of the rough opening and both bottom corners, over the aluminum tape.
Lift the new window's bottom two corners into the rough opening. Push the window up until it hits the stops. Hold a carpenter's square over the top left corner and adjust the window as necessary.
Insert wooden shims to fill the gap between the window's sides and the rough opening. Place the shims about 1 inch from each corner and near the window's center. Most windows have predrilled holes in these locations to indicate where to place the shims.
Drive screws through the predrilled holes, the wooden shims and into the rough opening. Cut along the shims where they extend past the window frame with a utility knife. Bend the shims back and forth to break them off along the cut line.
Fill the space between the window and the rough opening with expanding foam. Put the sash stops you removed in Step 1 back around the window and secure them in place with finishing nails and a pneumatic nail gun.
Go outside and push the foam backer rod into the gap between the window and rough opening. Use a putty knife to push the rod as far in as it will go. Run a bead of silicone caulk over the foam backer rod. Smooth the caulk with your finger.
Reinstall the interior and exterior trim pieces you removed in Step 2 around the window with finishing nails and a pneumatic nail gun.