Twelve hours after the voters of Maryland's 5th District elected him to Congress, Steny H. Hoyer journeyed to Capitol Hill yesterday and received a hero's welcome from his future Democratic colleagues who cheered his victory as a harbinger of better times.

Members of the House Democratic Caucus rose to their feet and applauded when House Speaker Thomas P. (Tip) O'Neill introduced Hoyer and spoke of his victory as a much-needed boost for the Democratic Party. Moments later they gave Hoyer a second standing ovation when he spoke of Tuesday's election as a sign of the party's continuing popularity.

For the next few hours on the Hill yesterday morning it was more of the same for Hoyer, who will not take the oath of office for two weeks. One for another, from Rep. James R. Jones, the chairman of the House Budget Committee, to Rep. Michael Barnes, Hoyer's Montgomery County counterpart, Democratic members of the House of Representatives told him, "We really needed this victory" as they pumped his hand in congradulation.

And although Hoyer's overwhelming victory in Tuesday's special election to replace Gladys Spellman was a personal triumph, it also was, the Democrats quickly made clear yesterday, a substantial victory for his party, even if it did occur in the highly Democratic northern Prince George's County district.

"The nice thing about this was that the people in the district decided the Democrat could best look after them," said Ann Lewis, political director of the Democratic National Committee. "We're still coping with the aftermath of the 1980 election and what it meant. This helps show that Democratic candidates and Democratic programs can be popular despite the high popularity of a Republican president."

Republicans, who had made a big push in the last few weeks for their candidate, Bowie Mayor Audrey Scott, through personal appeals by President Reagan and Vice President Bush, were equally quick to declare a partial victory in the 55 percent to 43.5 percent margin by which Scott lost to Hoyer. (Libertarian Party candidate Tom Mathers made up the difference in the margin.)

"We think it was an extremely strong showing on the part of the Republican candidate in a Democratic district," said White House Deputy Press Secretary Larry Speakes. Said Rep. Guy Vander Jagt, the chairman of the National Republican Congressional Committee which shepherded Scott campaign throughtout the six-week race, "She fought a good and hard campaign, coming close to defeating her opponent despite an overwhelming Democratic majority.Audrey's fine showing speaks well of the opportunity for Republican control of the House in 1982."

In fact, Scott's showing yesterday was not as good as the Republicans had predicted throughout the race. A poll the Scott camaign staff released about a month ago showed Scott losing by only six points and in the last week or so Scott's aides had repeatedly insised that the Hoyer margin had evaporated.

Buoyed by their polls, the Republicans mounted an intensive campaign to win a district that voted easily for Jimmy Carter in 1980, is dominated by federal workers and has a large percentage of black residents. The Republicans felt that the seat, held only seven years ago by a Republican, could be won despite the odds and committed themselves to an extraordinary push.

The race was important to the Republicans for several reasons. They were hoping to trim the Democratic majority in the House and demonstrate that the Republican momentum from the 1980 race was still there. In addition, special elections often are viewed as portents of the future and the Republicans, having won a string of such elections after Jimmy Carter was elected in 1976, were anxious to avoid a similar losing scorecard under Reagan.

So it was yesterday that Hoyer's victory and Scott's defeat could allow Democratic Party Chairman Charles T. Manatt to claim victory and call the election a "rejecion of the Reagan Social Security cutbacks and the Kemp-Roth tax scheme."

The congressman-elect was making no such grand statements yesterday as he held his first press conference in his new status. Hoyer said only that his victoy was the result of voters choosing between two candidates on the basis of qualifications and stands on issues.

Finally, after visiting members of Congress and looking over his temporary quarters in the Longworth House Office Building, where the 5th District office has been located since the seat was left vacant by Gladys Spellman's illness, Hoyer and his wife Judy drove back to his District Heights law office to return telephone calls.

And his campaign staffers -- now members of Hoyer's official transition team -- began the hectic process of locating office space, getting congressional identification cards, arranging for parking spaces and attending to all the minor items that go along with the honor of becoming the most junior member of the House of Representatives.