In the stairwell, go up to reach a dark corridor. Go through. There's a locked green door at the end, so go into the area just before it. There's a white wall in the distance that has flashing lights shining on it. Put a portal on it, then create a portal of the opposite color on the wall near you. Go through.
You end up in a small room with a door to GLaDOS emergency shutdown and cake dispensary. Open it (interact with it as if it were a red button.) Then a bunch of things will happen. Pick up Wheatley when he rolls over to you. When you're prompted to do a core transfer, put Wheatley into the receptacle.
When stalemate is detected, there will be a button up some stairs. But secretly there are walls that will prevent you from reaching it. So create a portal on one of the white walls in the room with the button, and create a portal of the other color on the nearby floor. Drop in and rush over to the button. If you don't reach it, keep trying different portal locations until you make it past the wall barrier. Then press the button.
After the next scenes, get into the elevator that appears. And then just watch.