Using a stud finder, locate the studs in the walls to which the the dividing wall will attach. Snap a chalk line along the floor between those two studs, and mark the spot where the door will be installed on the chalk line.
Cut two sill plates to fit the distance between the the wall and the edge of the door. These are pressure-treated 2-by-4 boards that provide a base for the framing.
Place the sill plates in position on the floor and screw them into the floor every 6 inches. Use galvanized screws for wooden floors or masonry screws for concrete floors.
Calculate the length of the wall studs by laying two untreated 2-by-4 boards on top of the sill plates and measuring the distance between them and the ceiling.
Measure the length of each sill plate and divide it by 16 to determine how many studs you need on each side of the door. You divide by 16 because the studs should be no more than 16 inches apart.
Cut a top plate for the frame that runs the entire length of the wall, and a bottom plate that matches the length of each sill plate, out of untreated 2-by-4 boards. Cut studs for the wall out of the same lumber.
Nail a stud onto each end of the two bottom plates, then nail more studs into the bottom plates between the end studs, spacing them no more than 16 inches apart.
Lay the two sections of the wall on the floor, aligning the bottom plates with the sill plates. Nail the top plate to the top of the studs.
Raise the wall frame so that the bottom plates are on top of and aligned with the sill plates. Nail the frame to the sill plates, studs in the adjoining walls and ceiling joists (use the stud finder to locate the ceiling joists).
Cut a 2-by-4 as tall as the door for each side of the door frame. These are the jack studs. Nail the jack studs to the the king studs, the ones on the sides of the doorway.
Measure the distance between the king studs and cut two 2-by-4s that length to be the door header. Stack the header boards on top of the jack studs and nail them to the jack studs.
Measure the distance between the top plate and the header, and cut a piece of 2-by-4 to match. This board is the cripple stud. Install it by placing it in position and nailing it to the header and top plate at an angle, using a method called toenailing. Keep the spacing between the cripple stud and king studs at no more than 16 inches; if necessary, cut another cripple stud.
Measure the height of the wall and subtract 1/4 inch, and cut 1/2-inch drywall boards to match.
Hold the first drywall sheet against the ceiling and the adjoining wall with the help of an assistant. Drive a drywall screw into the studs at the center of the sheet.
Screw more drywall screws through the drywall and into the framing every 16 inches. Screw the drywall to both the studs and the top and bottom plates.
Install the rest of the drywall, using the same process.
Apply joint compound to the joints between the drywall sheets with a 6-inch putty knife. Place strips of drywall tape into the joint compound, and run over them with the putty knife. Allow the joint compound to dry overnight.
Sand the joints smooth, then add another layer of joint compound and drywall tape. Allow that to dry overnight, then sand the joints and add a third layer of joint compound and drywall tape, going over it with a putty knife. Allow the third and final application of joint compound and drywall tape to dry overnight.
Raise the prehung door into place in the doorway, with the hinges on the correct side.
Center the door in the frame by sliding shims into the space between the door and the frame. Hold a level against the door frame and adjust the shims as needed.
Hammer 10d finishing nails through the door jambs and shims and into the framing around the door.
Trim the excess length of the shims off with a utility knife.
Cover the drywall with a coat of primer and allow it to dry.
Apply two coats of paint to the walls, allowing each coat to dry.
Nail the new trim around the door and molding to the base of the wall with 6d finishing nails.