This is a rush transcript from "The O'Reilly Factor," August 13, 2007. This copy may not be in its final form and may be updated.

BILL O'REILLY, HOST: In the "Campaign '08" segment, Senator John McCain. Tomorrow his new book, "Hard Call: Great Decisions and the Extraordinary People Who Made Them," will be released all over the country.

And one of the themes of the book is that tough decisions often go against public opinion.

Senator McCain joins us now from Charleston, South Carolina.

Senator, a couple of minutes ago, we had a segment on this program, where we discussed this guy, Carranza, illegal alien from Peru, allegedly raped a 5-year-old girl, had a number of assault beefs and now is charged with killing three college students. His bail was cut by a judge in Essex County, New Jersey, Judge Thomas Vena.

As president, what would you do to cut down on these kinds of atrocities by our legal system and the sanctuary city policies across the country?

SEN. JOHN MCCAIN, R-ARIZ., PRESIDENTIAL CANDIDATE: Well, I'd have a uniform federal policy, and I would begin absolutely with securing the borders.

The lesson I take from the last debate we were in, Bill, is that I still support the comprehensive approach to immigration reform, but we've got to secure the borders and it has to be done first. As president, I would say that the governors would have to certify that their borders, the border state governors would have to certify that their borders are secure.

Look, there's no confidence or trust left in the federal government after Katrina, after failures in Iraq, after corrupt congressmen going to jail, and so they didn't believe we'd secure the borders. I'd have to certify that. I would hope that if we seal the borders as much as possible, it would at least reduce the likelihood that someone like would come to — get into our country.

As far as the judge is concerned...

O'REILLY: I'd agree with you entirely. But would do support a law that compelled local and state authorities to report any illegal alien arrested for a felony to us? Would do support that law?

MCCAIN: Sure, sure.

O'REILLY: Because we don't have that.

MCCAIN: I also would support what ICE has announced, what Chertoff and Gutierrez have announced they're going to do. The numbers don't match up to — on Social Security numbers. And people who then knowingly have employed — and by the way, these are not small businesspeople. They're exempted.

But people who hire their people illegally and they don't have valid Social Security numbers, then they're going to be subject to prosecution.

O'REILLY: All right. Now, with all due respect, I'm going to tell you something you may or may not agree with. But I think that one of the things that hurt you in your presidential run was the perception by conservative America that you are an amnesty guy.

That when you were pictured with Ted Kennedy, in the photo ops for the comprehensive bill, many Americans said, look, and you pinpointed it, we don't have any confidence the federal government's going to shut this down. We see Ted Kennedy out there. We know he doesn't want to secure the borders. This is what conservatives are saying.

So when McCain is seen with Kennedy, that hurts you. Am I wrong?

MCCAIN: No, you're right. But it's not so much seen as we were unable to convince the American people that we were serious about securing the borders. As you know, in 1986, we passed a law. We said we'd secure the borders with Ronald Reagan under President Reagan. We said we'd secure the borders and gave amnesty. We gave the amnesty and didn't secure the borders. They didn't believe us.

O'REILLY: Now...

MCCAIN: When they don't believe you, then you're going to have to do something to convince them. One is restore trust and confidence in the office of the presidency and Congress.

And second of all, to say, look, we're going to secure the borders. And I think if the governor of my state, who happens to be a Democrat, would be forced she would certify that the border is secure, it would be secure. And that would give credibility. Well, all the border state governors.

O'REILLY: I don't know Napolitano. I don't know if she — I don't know.

MCCAIN: Let me just say, you'd have to have all the border state governors certify it. I think that would give credibility to our claim in Washington. That kind of thing. We've got to restore trust and confidence.

O'REILLY: Now...

MCCAIN: I agree with you.

O'REILLY: On page 279 of your book — and I'm enjoying the book, by the way. I hope people check it out.

You write about the Vietnam situation where the U.S. military wasn't defeated on the battlefield. But you also quote somebody who said, look, the people of the United States lost their commitment to the Vietnam War, therefore no army can function under that.

Many people say the same thing is going on in Iraq right now. Now, you've been an Iraq terror warrior. You've been out front on that. Another unpopular decision in America right now.

But Americans do have a legitimate gripe when they say, again, the U.S. hasn't been defeated militarily, but the Iraqi government is corrupt, on vacation, and they don't have confidence that our blood and treasure is going to be rewarded by these people in power in Iraq. How do you answer that?

MCCAIN: I answer that by setting out first priority is military, and we're winning. We're winning. It's not success; we're winning. And that's the facts on the ground.

And for four years, I have railed against the failed policy orchestrated by Donald Rumsfeld, and Americans are frustrated and saddened and angered. And again, a credibility problem because of things like "mission accomplished", "last throes", "few dead-enders", et cetera. In fact, when you look at it over time, the patience of the American people was quite good.

Now we have a strategy that's winning. What ought to give it a chance to win. Will — is the political situation? Yes. As you say, on the ground the political situation is improving in a lot of areas. I believe that the Maliki government must be told. And I call on them to act in a more inclusive and effective fashion.

O'REILLY: How much time do we give them? It's more than four years now.

MCCAIN: I don't know. I don't — I can't tell you what we — we have to do. It would be a terrible failing, obviously, but the fact is, you've got to secure things first, and that's what we're doing.

And there is, on the ground, in the local areas and in Baghdad. The political process is moving forward. Sunni and Shia are working together with U.S. military. Kurdish units are working with Sunni and Shia units. There is a lot of progress on the political, social and economic.

Does the Maliki government has to do better? Absolutely. I believe they will. I believe they will, my friend.

O'REILLY: One last question for you. The opposition to the Iraq war is hateful at this point, and I'm sure you know that. It's far beyond debates. It's a motion. And I only have 30 seconds for you here. I'm going to bring you back any time you want.

What is driving the hatred behind that war? Do you know?

MCCAIN: I don't know but they've lost sight of the fact that president's don't lose wars and parties don't lose wars. Nations lose wars.

And if we lose this war, they're going to follow us home. There's chaos, genocide in the region, and we'll pay a very heavy price. I'd much rather lose the campaign than lose the war. And I'm going to be in the debate in the middle of September when the Democrats try to give us a date for surrender.

O'REILLY: All right. Senator, we appreciate you coming on the program, and we'll see you soon.

Good luck with the book.

MCCAIN: Thank you, Bill.

Watch "The O'Reilly Factor" weeknights at 8 p.m. and 11 p.m. ET and listen to the "Radio Factor".

Copy: Content and Programming Copyright 2007 Fox News Network, LLC. ALL RIGHTS RESERVED. Transcription Copyright 2007 Voxant, Inc. (www.voxant.com), which takes sole responsibility for the accuracy of the transcription. ALL RIGHTS RESERVED. No license is granted to the user of this material except for the user's personal or internal use and, in such case, only one copy may be printed, nor shall user use any material for commercial purposes or in any fashion that may infringe upon Fox News Network, LLC'S and Voxant, Inc.'s copyrights or other proprietary rights or interests in the material. This is not a legal transcript for purposes of litigation.