Donald J. Devine, for four years the outspoken and controversial head of the nation's civil service, abruptly withdrew as a nominee for a second term at a dramatic Senate confirmation hearing yesterday.

Devine announced that he no longer wanted to be director of the Office of Personnel Management after strongly denying that he illegally extended his authority when his term expired or that he asked OPM acting director Loretta Cornelius to lie about her knowledge of that action.

"I should have perhaps done things differently . . .but it was clearly not my intention to hide anything . . . . I can absolutely and without any reservation tell you that I did not tell her or anyone else to lie," Devine said in his hour-long appearance before the Senate Governmental Affairs Committee.

After laying out his defense and taking credit for saving the government up to $6 billion while director, Devine pulled out a handwritten statement in which he said that although Republicans controlled the committee 7 to 6, he realized his nomination would be rejected.

"I am a political person . . . I can count the votes, and I don't believe that I have the votes," said Devine, who was accompanied by his wife and two of his five children. The family tearfully embraced several top OPM staff members immediately after his announcement, which caught many in the packed Senate hearing room by surprise.

Devine had a "damage assessment" discussion with advisers and White House officials Wednesday night following Cornelius' testimony, "and they realized it was going to be a long, drawn-out battle," said a ranking OPM official who asked not to be named. Devine drove home from the Capitol Hill meeting and, after discussion with his family, decided to withdraw, the official said.

Cornelius testified Wednesday that she had not been aware until April 29 that when Devine's term expired March 25 he signed a "delegation of authority" order giving him the OPM director's powers. Cornelius was supposed to be running the agency while Devine worked temporarily as her executive assistant. She said that Devine, fearing "how damaging" his failure to tell her would look to the Senate, asked if she could say she had been informed.

Congressional sources said the Cornelius testimony prompted White House officials to pressure Devine to withdraw because it was evident that he had lost Republican support.

But Devine said he was not asked to withdraw and said he made the final decision yesterday morning while driving to Capitol Hill from his home in Wheaton.

Presidential spokesman Larry Speakes said Devine's decision was "his choice" and had not been suggested by anyone at the White House. No new nomination was made, and Cornelius, 49, a former corporate personnel executive, will temporarily continue running OPM.

"Dr. Devine, I think you have taken the only honorable decision under the circumstances," said Sen. Ted Stevens (R-Alaska), chairman of the civil service subcommittee, who had been considered a Devine supporter but was visibly upset by Wednesday's disclosures.

Devine said in an interview he believed that Stevens, Sen. Charles McC. Mathias Jr. (R-Md.) and the six committee Democrats would have voted against him. "They don't like the policies I have been following," he said, "I was trying to change things and they basically represent the status quo." Neither Republican senator could be reached for comment, but Mathias said earlier that Devine's actions regarding the delegation order represented "a serious breach of law."

After the Cornelius testimony, Devine received a message from Stevens that his nomination was doomed, according to GOP sources. "He was told it was a lose-lose situation, that a lot of careers would be ruined and that the president would be embarrassed" if the hearings and vote dragged on, a Republican staffer said.

Devine, 48, a former University of Maryland political scientist and conservative activist, was the architect of controversial Reagan personnel policies, including reducing the size of the federal work force and proposing to reduce pay and curtail health benefits. Devine's use of a new merit system to determine employes' pay raises and priority for layoff was also controversial.

The General Accounting Office said that Devine's March 25 order was illegal because it "circumvented" the four-year term of office. But Devine said the opinion was wrong because he did not act as director between March 25 and May 1, when he resigned after Cornelius threatened to fire him.

During those five weeks, Cornelius made 55 decisions and Devine made only seven "minor" decisions, a record that Devine said showed he had not tried to illegally usurp her power. Sen. Thomas F. Eagleton (D-Mo.), Devine's chief critic, disputed that, calling the matter "an act of illegality and stealth unbefitting a high public official."

Devine said yesterday that he had not intended to hide the order from Cornelius. "I just frankly didn't show it to her, and that may have been a mistake . . . . It was a mistake . . . . I put it in my files, and forgot about it."

He said Cornelius "misunderstood" their April 29 discussion of his failure to inform her. Because Cornelius had seen the "position description" setting up broad powers for Devine's new job as her assistant, Devine said, he believed that she knew he could still act as director.

He said he asked Cornelius, "If you know about the position description, couldn't you say you knew about the delegation of authority?" He said she misinterpreted that as a request to lie. "Perhaps I was not as clear and lucid as I could have been," he said.

Devine is currently working at the Heritage Foundation. The Marylander has been mentioned as a possible House or Senate candidate, but he would not discuss his plans.