The mayor's speech about "the importance of community" lasted only a few minutes, but that was just long enough for the soft gray of twilight to give way to the deep black of night. Perfect timing! The stage was set for the big event.

The townspeople gathered here on the steps of the Douglas County Courthouse joined in a loud countdown.

When it ended, the lights of a 40-foot-tall Christmas star mounted high atop the town's eponymous rock flashed on.

For the 49th year, the people of this high plains community had celebrated the lighting of "The Star at Castle Rock."

Back in 1936, when the town elders first erected the star above the highway running north to Denver, the purpose was partly to spread Christmas cheer and partly to remind the outside world of the existence of this small town at the base of the big rock.

But today Castle Rock finds itself smack in the path of a historic migration: the Sun Belt shift.

The small town is becoming a big one; and in those circumstances, the annual star-lighting ceremony here has a new purpose.

"We're here to light the star," said Mayor George Kennedy in that perfectly timed speech Saturday night.

"But we're also here to remind ourselves of the importance of community."

Maintaining a sense of community has become an important but elusive goal for towns all over the South and West that are absorbing the great migration of Americans who are trickling out of the Northeast and Midwest and flooding into places like Douglas County and its county seat, Castle Rock.

The census data vividly demonstrate the dilemma here. Douglas County's population grew from 8,407 in 1970 to 25,153 in 1980.

That growth rate -- 199 per cent -- made it the second-fastest growing county in the nation, according to the Census Bureau. (The fastest was Summit Coun- ty, Colo., to the northwest of here.)

The town of Castle Rock doubled in population -- to about 7,000 -- in the same decade, and planners say it will be a full-fledged city of 30,000 by the end of the 1980s.

There has been some muted criticism of this sudden growth, but little has been done to stop it.

For one thing, some old landowners are getting rich; for another, the strong sense of personal freedom here precludes the governmental controls over development that are common in the East.

Still, the change in the town's nature is something people notice every day. Sam Swearingen, proprietor of a jeans-and-boots shop on Castle Rock's main street says, "There are people coming in my store that I don't even know."

There's also been a qualitative change as this erstwhile rural outpost takes in thousands of newcomers for whom a "mustang" is a kind of car.

The Montgomery Ward catalog store has been replaced by an art gallery, and Hi's Western Store has turned one room formerly devoted to tack and saddlery into a videotape outlet.

The cattle that grazed just three years ago at the edge of the Safeway parking lot were evicted to make way for a golf course.

"There are more people in the county than ever, but they don't join 4-H, they don't go to the county fair," says Jean Stanwood, a 4-H leader who lives in the rolling hills west of town. "And so you just don't meet them."

And so, like other population magnets throughout the burgeoning Rocky Mountain west, Castle Rock is making a determined effort to maintain something of its small-town aura despite the looming threat of big-city status.

The star-lighting cere- mony Saturday was part of that drive.

Entertainment was provided by the Castle Rock Municipal Band. Founded in the early 20th century, this small organization was defunct for 50 years -- and then revived this summer to help recreate the old town spirit.

A long-time resident recited the traditional poem, "The Star of Castle Rock," featured at the star-lighting ceremony for four decades ("May this, the Star of Castle Rock/ Shine forth for Peace on Earth.")

Mayor Kennedy then stepped up to the microphone and made his brief but heartfelt plea for "a feeling of community in our town."

With that, the assembled townspeople turned to face the towering rock.

At the end of their countdown, a brilliant star-shaped bank of lights flashed on in the north, and the town responded with an enormous cheer -- a cheer that seemed full of Christmas and full of community.