(FORTUNE Magazine) – Surrounded by files and packing cartons, outgoing White House Chief of Staff Leon Panetta is busy cleaning out his West Wing office these days. He seems palpably eager to get out of Washington and return to his beloved California. After he's relaxed awhile and hit the lecture circuit, he may make a run for governor of his home state, which he represented in Congress for 16 years. His legislative and management experience, combined with his wicked sense of humor and legendary toughness, may make him a formidable candidate.

Panetta, 58, leaves the capital justifiably proud of his management record at the White House, having instilled much needed discipline into the operation. When he arrived in July 1994, the place seemed to house an out-of-control kindergarten class. Panetta's predecessor, President Clinton's longtime friend Thomas "Mack" McLarty, had been a successful ceo of the giant Arkla gas company. But with no prior Washington experience, he was badly miscast as master of Clinton's policy agenda and schedule. Panetta, former director of the Office of Management and Budget and a moderate Democrat, spoke recently with FORTUNE contributing editor Christopher Ogden about how he brought order to a White House infamous for preternatural disarray. Excerpts from their conversation:

You had a reputation when you came in from OMB of being a good manager, so is that what the chief of Staff job takes?

You find out very quickly what you don't know when you get into this job. It's not so much a management job as it is a battlefield position that requires skills above and beyond your talent to manage people.

What kind of organization did you find?

The fundamental problem was that there was no organization chart. No chain of command. People were not sure who they reported to. There were people with titles like "counselor to the president" who had no definitive responsibilities. They wandered the halls and in and out of meetings giving advice but never had to deliver. There was an aura of chaos.

How did you set about making changes?

I started by trying to put together an organization chart. Before I could even begin to restructure, I had to have a sense of exactly what people were doing and how they related to the president.

How did you pick staff?

I wanted first to look at everyone already in position. The president and Mack gave me their views about people's capabilities, but I didn't want to prejudge without giving them an opportunity to work under my leadership and this different structure. To ensure a proper chain of command, I thought there should be two deputies. Then I brought in a few key staffers who'd been with me since my congressional office to handle administration, legislative and foreign matters, and scheduling. When you move into that kind of operation, you want people whose skills you know, whose loyalty to you is unquestioned, and who are going to protect your back.

Once you had your back covered and you were reaching further afield, what kind of people did you look for?

People who had experience and who could assume responsibility. One of the problems the first two years was a general lack of experience about how both government and this town work. I did not want to repeat that mistake. Kitty Higgins from the Labor department became cabinet secretary because she knew what was involved in running a department and how that related to the White House. Mike McCurry came in as press secretary. He was an experienced guy and had done well working for Warren Christopher at the State Department. Originally there had been a communications operation under the press secretary. It didn't work. Communications, getting the President's message out, became a separate operation, and that helped.

Another key job was the counsel to the President. I had known Ab Mikva from my days in Congress and had great respect for his credibility and integrity. I felt that was important for a job where you've got a lot of mortar shells coming in.

How do you tailor advice to a president who is very bright but loves endless options and delays decisions to the last moment?

I found early on that the best way to bring different viewpoints into my office was to sit around and let policy people work through their options. That way you have a better sense of the conflicts. Then I would prepare a memorandum for the president, laying out the issues and options available. If he wanted, I'd bring the key people into the Oval Office to walk him through the options. Then it was up to me to force the decision.

Whom did you approach when you needed extra advice? It varied a great deal. One of my advantages was that with experience on Capitol Hill and at OMB, I was familiar with many of the issues that ultimately had to go to him. I had a pretty good sense of whom you could rely on within staff or around the Cabinet departments or on the Hill. I tried to develop as much consensus as I could. If you got everybody to agree, that was a pretty good indication the president would go along.

What about your dealings with Congress?

If there was a high-profile Hill issue, I would meet with [House Minority leader Richard] Gephardt or [Senate Minority Leader Tom] Daschle and have a pretty good idea what their position was and what they thought was going to happen. I'd also talk to [former Senate majority leader Bob] Dole and [House Speaker Newt] Gingrich by phone. It goes back to the battlefield. You need to know where the land mines are, where the enemy troops are, and then develop a battle plan to deploy your own forces. Basically, you're gathering intelligence so the President isn't blind-sided. The greatest danger is that you don't consider all the possibilities, and your biggest job is to make sure you're ahead of everybody. It's hard.

How do you deal with a staff that you don't completely control and get bright people to do some things they don't want to do?

The key remains loyalty. If you build loyalty on a team, you can have the brightest people and you don't have to fear their intelligence, because they are loyal to you and will let you know when problems arise. They've also got to know there is a clear mission and responsibility and that you will be very firm with them. That demands personal involvement. That's why it was important to bring people in to make them feel they were not being bypassed.

How did you determine access?

First and foremost, it was important that nobody could just walk into the Oval Office. There were problems before I got there with people just walking in, so that had to be controlled. I made sure with the secretaries in the outer Oval Office that we knew what the schedule was each day and who would be seeing him. If it was a personal friend of the president's, we'd ask; and if he wanted to see him, that was fine. But staff wouldn't go in unless I cleared them.

How'd you deal with Dick Morris, the prince of pop-in?

Morris became a problem. At first, he operated as a political consultant and would come to political meetings and provide guidance. But then he got involved with issues and talking with staff. I immediately went to the President and said that shouldn't happen. All the discipline we have put in place will be undermined. To his credit, the president said Morris had to work within my rules. So we made it clear Morris could not talk to anybody on the staff without clearance from me or one of the deputies. And he pretty much abided by that. Even when he had a "brilliant idea" every 20 minutes, we made it clear that it would not move forward unless it had been fully vetted.

Is it fair to call you a control freak?

I'm a knowledge freak. I want to know everything that's going on. I wanted the chief of staff's office to be the funnel to the President on all issues. You can call me a control freak, but the staff was relieved when I arrived. When they came to me and said they needed a decision, I'd make one. My father taught me that you have to make decisions and move on, because you'll soon be facing other decisions. He was an immigrant from Italy who ran a restaurant in Monterey, and I remember as a kid working next to him and learning what work was really all about.

How do you organize your day?

Mack had an 8:15 a.m. broad staff meeting; then after that he'd have a smaller group go to his office. I reversed that and had a 7:30 a.m. key staff meeting of about a dozen people, the head of the NEC [National Economic Council], NSC [National Security Council], the press person, the key deputies. We'd go over the president's schedule, discuss the key event that day--Was everything prepared? Were the statements written? Then I walked through a yellow sheet, which always had the same headings: foreign affairs, domestic affairs, legislation, and what was happening on the Hill. Then economic--Were any statistics coming out that day? Then political and legal (which became a section nobody looked forward to).

How much technology did you use to make the place operate?

We had e-mail, but my primary vehicle was that yellow pad. I'm computer literate, but I didn't spend much time on mine. So much of your day is spent running from meeting to meeting. There's no question the White House would benefit from better technology. There's much too much time spent moving documents around. The problem is, you have to go hat in hand to the Congress for money, and they're very suspect when you do. It's not like business, where you can make the investment. The White House ought to be at the cutting edge of technology, but it was nowhere near there when we came in.

How do you have a life in this job and avoid staff burnout?

It's a big problem. People are in by 7 a.m. and work until 8 or 9 p.m. and weekends. In Congress, I would go back to my district every weekend. That lets you break out of the Beltway mentality and get back a sense of balance. But God blessed me with a sense of humor, which has helped me maintain a sense of perspective. I always tried to make people understand that even in the worst crisis, you have to learn how to keep things in perspective. Secondly, I urged people to take time with their families, because I really think if people lose their humanity in these jobs they're not worth much--whatever their brainpower may be.

Knowing what you know now, if you were to do this over again, what would you do differently with the staff or the president?

I would have moved quicker to make changes I thought were needed. As for dealing with the president, you have to be direct with him. If there's an inherent weakness in the process, it's that staff people by nature don't want to tell the president bad news. I found the sooner you tell him about problems, the better off everybody is.

You're going home to California, perhaps to run for governor. In fact, would you like to declare right now? Whatever you do, what from this experience will make you a better executive?

I haven't decided yet about the governorship. I'll look at that possibility after I get back to Carmel Valley and decompress for a while. But I don't think there is any position in this country that can better prepare you for an executive job or a leadership position in government than chief of staff to the president. You have to deal with every issue and every crisis imaginable, and there's a lot riding on your decisions.