Bob Cook, one of two Republicans campaigning against former congressman Robert E. Bauman in Maryland's 1st Congressional District, will withdraw from the race today and throw his backing to former State Sen. C. A. Porter Hopkins, according to sources close to the campaign.

Cook and Hopkins, both of whom have said they are in the race to provide "an alternative" to Bauman, scheduled a joint press conference in Easton. In his speech, written earlier this week, Cook plans to say he is withdrawing "for the unity of the Republican Party."

The move is surprising to 1st District Republicans because Cook, a Salisbury businessman, had run a more aggressive campaign than Hopkins, who retired from the State Senate six years ago.

Bauman was the first Republican to enter the race, announcing last November that he would seek the seat he lost to Democrat Roy Dyson in 1980. Bauman lost the seat he had held for seven years a month after he was charged with soliciting sex from a teen-age boy. He pleaded innocent, entered a court-supervised rehabilitation program as part of a court agreement, and issued a statement admitting "twin compulsions," alcoholism and homosexuality."

Hopkins entered the race next, saying he wanted to give voters an alternative to Bauman and attacking him for "exposing the voters to his personal problems." Cook began an aggressive campaign a month ago.

Many Republicans expected Hopkins to withdraw to avoid splitting the anti-Bauman vote in the Sept. 14 GOP primary. But, sources said yesterday, Hopkins refused to drop out and Cook decided the only way to beat Bauman in that case was to withdraw himself.

"One down, one to go," Bauman said yesterday afternoon. "I'm very much encouraged by this. I think we're going to win the primary and Mr. Cook apparently senses that, too.

"I felt confident we would beat Mr. Hopkins when he first got in and I still do. I think the primary is going to be a springboard into the general election for me and this announcement is an indication that I'm the man to beat in this primary and the focus is still very much on me."