The Montgomery County executive's race this fall is shaping up largely into a referendum on Reaganomics, pitting a Democratic incumbent in a moderate Democratic county against a Republican believer in President Reagan's conservative economic policies.

County Executive Charles W. Gilchrist, who piled up a 2-to-1 victory margin over a relatively unknown challenger, is planning to campaign as a defender of traditional Democratic values against the threat of federal layoffs and program cutbacks to local governments.

Republican candidate Joseph C. McGrath, who won 41 percent of the GOP vote against two strong challengers, said he welcomes the chance to trumpet his support for Reagan and traditional Republican free-enterprise policies in a county he sees growing more conservative.

"I think Reagan's got the best program on the table and he's taking us in the right direction," McGrath said yesterday. "I think this is going to be a referendum on which way Montgomery County is going to go in the 1980s."

"This is likely to be a referendum on the kinds of economic and social views that Reagan and McGrath subscribe to," said Edmond F. Rovner, Gilchrist's executive assistant. "I don't think it's a question of hanging Reagan around McGrath's neck -- McGrath thinks Reagan's an ornament. They both read from the same hymnal."

McGrath, a former vice president of American Security Bank, was able to pull out of the three-way GOP pack precisely because of his traditional Republicanism. While avoiding being cast as a right-winger, McGrath appealed to party conservatives, who were angry with GOP executive candidate Luiz R. Simmons, a moderate-to-liberal one-term delegate.

Democratic party leaders said yesterday that they welcomed the chance to run a contest of philosophies between Gilchrist and McGrath, instead of a race against Simmons which, in Rovner's words, "would have been trickier." Simmons would have tried to appeal to Democratic voters by painting himself as a liberal Republican, in the tradition of Sen. Charles McC. Mathias.

McGrath said he, too, will appeal for Democratic votes. He said if he can hold onto Republicans, who make up 30 percent of the county's registered voters, and attract independents, who make up 17 percent, he will not need many Democratic votes to win.

If McGrath's victory Tuesday was good news to Gilchrist, it was tempered by Gilchrist's severe setbacks in the divisive County Council race and the 16th Legislative District race.

Gilchrist had hoped to carry with him into the general election a seven-member council slate largely of his own making, and purged of his most outspoken Democratic party critics on the council, Esther P. Gelman, Michael Gudis and David Scull.

Gilchrist helped form a slate, called United Democrats, with Council President Neal Potter, and members Rose Crenca, Scott Fosler and Ruth Spector and three nonincumbent candidates. Gelman, Scull and Gudis formed their own slate, called the Merit Team, and recruited former Rockville Mayor William Hanna Jr. to fill in one of the four open slots.

When the votes were tallied, every incumbent won easily except for Spector, who lost to Hanna. Spector's defeat, particularly bruising for Gilchrist since the two are close personal friends, would shift the council from a 4-to-3 pro-Gilchrist majority to a 4-to-3 majority of his critics, pledged to a more independent council.

Also, Gilchrist's close friend and advisor, John J. (Jack) Sexton, lost the Democratic 16th district primary race to Brian Frosh, a liberal attorney who was endorsed by Gelman's Merit Team and received some last-minute assistance from the slate in mailing his literature.

Gilchrist and his campaign chairman Gilbert B. Lessenco visited the Merit Team headquarters Tuesday night, to offer congratulations after a primary campaign that turned increasingly personal and bitter in the closing two weeks.

The wounds from that primary are deep, and show no signs of healing at least in the next few days. "We need some serious discussions about how the two levels of government will function," Gelman said.

State Sen. Sidney Kramer said he will begin building bridges between the two camps, so the Democrats can hold their traditional "kiss-and-make-up" party within two weeks.

Kramer's job will not be easy, said another party leader, outgoing State Sen. Victor L. Crawford. "They spent thousands of dollars, for nothing. It's a dammed shame, but that's the Democrats for you. Now there's going to be a hell of a chore, getting Esther Gelman talking to Neal Potter and Neal Potter talking to David Scull. If you can figure out a way to do that, you're a better man than me."