In this tiny town billed as the "ham capital of the world," Joseph W. Luter III is riding high.

A boyish-looking, soft-spoken executive, Luter, 43, has rescued Smithfield Foods Inc. from the brink of bankruptcy and built it into the biggest producer of ham, bacon, sausages, hot dogs, bologna and pork products on the East Coast.

Today, the formerly scandal-ridden company is touted by investment analysts. It is vying for a rung on the Fortune 500 ladder.

"We've come a long way in less than eight years," Luter said in a recent interview. "We move quickly. . . . We make decisions fast."

In one bold step, Luter's company gobbled up its chief rival, Gwaltney of Smithfield, thereby doubling its size and capturing rights to nearly all the hams cured under the "genuine" Smithfield label, a trademark known to pork lovers across the nation.

Along with Gwaltney, Luter's enterprise also swallowed up what is described as the world's largest hot dog plant--a Portsmouth, Va., outfit that can spew out 16.8 million frankfurters a week during its busy summer season.

Luter--the dominant figure in Smithfield Foods, controling 38.6 percent of its stock and holding titles as president, chairman and chief executive officer--remains on the lookout for possible new purchases. Last summer, Smithfield Foods took over a small North Carolina firm to boost its country ham output. Smithfield would buy again, Luter said, "if the deal was attractive enough."

Today, Luter's company is a mixture of Old Dominion traditions and fast-food technology. Richly flavored, mahogany-colored Smithfield hams are still aged in wooden racks over oak and hickory fires in a smokehouse built 47 years ago. Yet its Portsmouth hot dog plant has gadgets that stuff 160-foot cellulose tubes with meat shaped into 5 1/4-inch franks in a mere 45 seconds.

Luter commutes in a twin-engine company plane from his new headquarters in Rosslyn to his long-established plants in this Tidewater town, situated on the banks of the Pagan River, a James River tributary. The town (population 3,718) is surrounded by soybean, peanut and corn fields and dotted with stately homes dating from the 18th century.

The company's darkest days occurred in the late 1960s and early 1970s, after the enterprise was taken over by Liberty Equities Corp., a fast-paced holding company run by a flamboyant businesman, C. Wyatt Dickerson Jr. The venture was soon sued for alleged fraud by the Securities and Exchange Commission. Amid a flurry of management shifts and subsidiary selloffs, the company headed into a financial skid.

Luter, who had sold out in 1969, returned six years later to try to resuscitate the business, which his family had founded. "I really didn't want to see a company that my father and my grandfather spent their life in fail. And I really didn't see any reason why it should fail," Luter recalled last week.

Even today, the corporation's outlook is not altogether clear. Smithfield Foods reported losses during two recent quarters, the latest ending Oct. 31, though company officials say they expect to show a profit for the three-month fall-to-winter season, normally the ham industry's peak.

The firm has faced a protracted earnings squeeze stemming from high prices it has had to pay for hogs. The company, which slaughters about 13,500 hogs a day, buys the animals from farmers and dealers from the Mid-Atlantic region to the Midwest. Currently, hogs are selling for close to $60 per 100 pounds of weight, far above the $43 Luter's company was paying a year ago and the $29 cost in 1980.

Jens Knutson, an American Meat Institute economist, and other industry analysts forecast a possible price drop by next fall, though they describe the market as too volatile for easy prediction. "As hog prices decline, Smithfield's earnings should improve substantially," Wheat, First Securities Inc. concluded in a recent report.

Investment analysts also caution that Smithfield Foods' long-term prospects are closely linked to Luter. "We believe Joe Luter is the key figure in the future of Smithfield. Our opinion of the stock may well be modified if his association with Smithfield ends for any reason," said Scott & Stringfellow Inc., a Richmond-based brokerage house.

A parallel issue was raised in a report by the Investment Corp. of Virginia, a regional Norfolk brokerage: "Both Smithfield Foods and Gwaltney of Smithfield have operated under three separate owners within the past 15 years. We cannot overlook this potential for acquisition at a profitable premium above today's market price within a five-year horizon."

To such speculation, Luter had a firm retort. "I plan to stay for the foreseeable future," he said. "The company is not for sale."

Luter's home town laid claim to the "genuine" Smithfield label under a 1926 Virginia law that restricted the prestigious designation to hams cured and smoked within the town's limits and cut from hogs raised in the Virginia and North Carolina peanut belt. Most Smithfield hams are aged for nine to 12 months, company officials say.

Although the "genuine" Smithfield imprint has given the town's hams a special status, the 120,000 or so Smithfield hams sold yearly by Smithfield Foods represent a miniscule portion of the company's output--no more than 1 percent, according to Luter. The firm, which owns nine plants in Virginia and North Carolina, also markets a wide array of processed meats with brand names including Luter, Jamestown, Gwaltney, Williamsburg and Olde Smithfield, along with poultry products under the Great label.

In the town of Smithfield, Luter's company no longer faces significant competition. Only two tiny pork producers remain--V. W. Joyner and Co., a Swift & Co. ham-making subsidiary, and Smithfield Ham and Products Co., an independent firm that mainly sells canned foods. "We're not really in competition with them," said V. W. Joyner's plant manager, J. D. Cranford. "We're very small." So small is Joyner that no record of the plant's existence could be found last week by the public relations office of Esmark Inc., Swift's parent.

In the highly fragmented pork processing industry, Smithfield Foods has emerged as a regional powerhouse by grabbing about 3 or 4 percent of the total U.S. pig kill. The company's sales climbed to $344 million in its 1982 fiscal year, chiefly because of its Gwaltney takeover, and Luter predicted the 1983 figure will approach $600 million. Smithfield is outranked, industry officials say, by several Midwest and Western companies with nationwide markets, such as Armour and Co., John Morrell & Co., Oscar Mayer Foods Corp. and Swift.

Smithfield Foods' roller coaster history began in 1936 when Luter's father and grandfather, Joseph Luter Jr. and Sr., quit their jobs at Gwaltney, which had been making hams since the 19th century, to start their own smokehouse beside the Pagan on the town's bustling waterfront. After his father's death in 1962, Luter climbed swiftly up the company ladder, gained control of 51 percent of its stock and emerged as president four years later at the age of 26.

Luter apparently had no plans to quit his family's business, then called Smithfield Packing Co., when he was offered a deal too big to turn down. The company was sold to Liberty Equities in 1969 for $20 million. The SEC went to court a year later, accusing the firm of fraudulently inflating its financial statements. Dickerson stepped aside. The SEC action and a separate stockholders' suit were settled. New officers tried to revive the company, eventually selling off Liberty's seafood, lighting fixture, real estate and other subsidiaries.

But with hog prices rising and the firm's chief lender, United Virginia Bank, pressing for further financial salvage work, the company faced renewed troubles. Luter, who was working on a real estate venture in Virginia's Shenandoah Valley resort region, offered to return in 1975. What shocked him most, Luter said later, was that the packing company had taken a loss during its traditionally prosperous Thanksgiving and Christmas season.

Since Luter's comeback, Smithfield's biggest move was the takeover of Gwaltney in October 1981 for nearly $34.1 million. Smithfield and Gwaltney had been ardent rivals for decades, and some industry officials say that Gwaltney would never have acceded to the deal if Gwaltney itself had not been acquired 11 years earlier by Continental Baking Co., an International Telephone and Telegraph Corp. subsidiary.

"That was something of a surprise when the two got together," said John Mohay, president of the National Meat Association, a packers' trade group. "They were rivals--and strong rivals. . . . If one of them was a customer, the other wouldn't buy from you."

Continental Baking was prepared to sell Gwaltney, a Continental spokesman said, because of a new strategy aimed at unloading enterprises outside the baking business. "We decided to concentrate on doing what we do best and that's being a baking company," the spokesman said.

Even under his expanded corporate umbrella, Luter has sought to maintain the traditional rivalry between the Smithfield and Gwaltney subsidiaries. "They actually compete against each other," he said. "It gives us a yardstick. We would never consolidate the two companies from a sales standpoint because we feel we would lose market share."

Luter, who was paid $266,016 last year, has moved steadily to boost his company's earnings by cutting costs and increasing his plants' output. About $1 million was saved, chiefly by eliminating about 35 middle-level jobs after the Gwaltney takeover, Luter said. Smithfield's slaughtering room has been enlarged and new machinery installed at the main plants to speed up pork curing and packing. By next summer, Luter said, the company will kill up to 15,000 hogs a day, a 50 percent increase over 1981.

At the Gwaltney plant here, Vernon Carr, a quality control foreman, pointed to a machine that stuffed hunks of pork into special casings. "We used to hand-stuff just about everything," he recalled.

Smithfield Foods has also moved quickly, officials say, to take advantage of new Interstate Commerce Commission rules by hiring out its fleet of 120 refrigerated trucks to haul other companies' freight. In the past, Smithfield's trucks had to return empty after delivering their pork. Now the return trips may pick up extra revenues for Smithfield.

Despite faster assembly lines, where fat and bone are trimmed, and new ham curing contraptions, some techniques at Smithfield have resisted change. "You're looking at 1936 vintage here," Luter said as he strolled through the smokehouse his father and grandfather had opened. "You smoke them in the old-fashioned way."