Just a few months ago, this remote city near the Pakistani border was tense and cowed. Turbaned gunmen swaggered through bazaars, the streets were empty by dusk, and the newly appointed governor was virtually under house arrest.

Today, Khost is a town transformed. The militiamen and their renegade leader are gone, and the bustling streets are patrolled by smartly dressed army troops loyal to the governor. A university has been established, a music festival was recently held at the soccer stadium, and there are plans to rebuild the long-closed movie theater.

"We have more peace and quiet here now than we have had in the past 23 years," said Mohammed Zaher, 45, a laborer. "The authorities are in control and paying attention to our problems. Now that we have a university for our sons to attend, maybe the culture of the pen will start replacing the culture of the gun."

But a shadow looms over this promising scenario. Every few days another rocket lands somewhere near the city or one of several U.S. military bases in surrounding Khost province. The attacks come from the direction of Pakistan, where remnants of al Qaeda and the Taliban movement have found refuge in the lawless tribal areas that hug the border.

Although many of Afghanistan's 30 provinces suffer from the same problems that have long held Khost back -- rural poverty, illiteracy, wartime disruptions and tribal resistance to change -- this particular corner of Afghanistan is additionally plagued by its past notoriety as a Taliban stronghold and by its present vulnerability to attack from Islamic militants who fled across the border when U.S. forces and their allies toppled the Taliban last year.

Despite periodic sweeps by American combat troops through the frontier region, the number of rocket attacks on U.S. bases and outposts in Khost and the neighboring border provinces has remained consistently high -- about 50 per month since the summer; 55 in November -- and their audacity has increased.

One reason is that, for the first time, guerrillas inside Pakistan are beginning to sneak into Afghanistan for brief hits, according to U.S. and Afghan military officials. This month, they said, a group crept across the border, fired rockets close to a U.S. Special Forces camp in the village of Lawara and scrambled back through the wooded hills into Pakistan, evading efforts by U.S. helicopters and planes to shoot them.

"The launching site was right on the border, about three miles from the base," said Col. Roger King, U.S. military spokesman at Bagram air base near Kabul. Lawara is about a five-hour drive from the city of Khost, just over the Paktika province line. The attackers try to avoid capture by "using delay-timing devices, leaning the rockets against a rock and then taking off," King said.

For the most part, however, the rocket attacks have been amateurish and inaccurate, almost never hitting their apparent targets. Earlier this month, one hot-wired rocket, fired from the hills just inside Afghanistan, landed in Zamar Jan's clover patch about 1,000 yards from the U.S. military-controlled Khost airport, injuring his cow. The next day, four more landed in a village on the other side of the city, doing little damage.

"They use radio batteries and cross two electrical wires to fire them. It is not a big or organized threat, it is just intended to bother people," said Gen. Mohammed Nawab, deputy commander of the Afghan army's Khost division. "But the border is very long, the hills are low and easy to cross, and we can't post soldiers along every meter. So we expect this will go on for a long time."

In the border village of Ghulam Khan, a two-hour drive from the city, the tension is palpable.

Afghan troops do not dare venture closer than a hilltop overlooking the frontier, where Pakistan's paved roads and power poles abruptly end and a rough dirt track begins. The actual line is a disputed no man's land, and historical Afghan suspicions of Pakistani designs seem deeper than ever.

Badar Khan, leader of the local Ghor Baz tribe, said he and his armed followers would love nothing more than to attack Pakistan. He said he was sure former members of the Taliban were living freely in the town just beyond the border, a major crossing point for cargo trucks full of Pakistani cattle and tires.

"Our ancestors fought to defend this territory, and we will never concede a centimeter of land to Pakistan," Khan vowed. "We know their [intelligence agencies] are openly helping the Taliban, going to mosques and telling boys not to go to Palestine to fight the holy war there now, because the infidels have come to Afghanistan and they should fight here."

U.S. forces stationed here -- including combat troops, civic affairs teams and Special Forces -- are also on permanent alert because of their proximity to the border. Although not outwardly concerned about the stray rocket attacks, Special Forces officers at one base in the city recently said their greatest fear was that once the U.S. military left the region, Taliban and al Qaeda forces would quickly return.

As far as Afghan officials are concerned, a more immediate and worrisome threat to regional security has been eliminated with the recent quashing of Bacha Khan, a local militia leader and former U.S. ally who helped drive Taliban forces from the region but then refused to accept government authority and continually tried to shoot his way into power.

Bacha Khan and his loyalists are now a relatively harmless pariah band confined to a small rural area in neighboring Paktia province. Some of his former troops, despite being recruited by U.S. forces, continue to cause trouble here by harassing civilians or stealing, but Afghan army officials are quick to disarm them and alert local U.S. bases.

In the streets of Khost, the departure of Bacha Khan's abusive gunmen was as welcome as that of the Taliban's dreaded religious police force. Music now pours from cassette shops, barbers trim men's fashionably long hair, and the only rifles visible in public are carried by police and army troops in crisp green uniforms.

At an official celebration recently for the Muslim holiday of Eid, thousands of young men flooded into the Khost stadium, many wearing festive traditional tunics of lilac, sky blue or canary hue, for a day-long program of traditional song and dance -- an event unthinkable under either the severe strictures of the Taliban or the violent threat of Bacha Khan's fighters.

"You can feel the difference, now that Bacha Khan is gone and we have a real government to defend us," said Mohammedullah, 30, a barber who returned in October from eight years' exile in the United Arab Emirates. His shop was crammed with men waiting to have their beards and luxuriant locks trimmed.

"When the Taliban were here, there was no work for someone like me," he said. "Now I have plenty of customers."

The most remarkable harbinger of change, though, has been the opening of Khost Afghan University. The school was previously based in Peshawar, Pakistan, as part of a campus set up years ago for Afghans who had taken refuge from the war. This summer that institution was shut down, and about 1,000 students -- along with their desks, computers and medical lab equipment -- decamped in October to a former German technical school here.

The government in Kabul deliberately chose Khost, a prosperous but isolated and educationally backward city, as the campus site, despite concerns about student safety. Officials here, including the army commander, are enthusiastic supporters of the university, which they envision jump-starting Khost's transformation from a tribal, pro-Taliban backwater to a fast-developing provincial seat.

"The university is the light of Khost. It will revolutionize the area," said Gen. Khel Bas, the regional army chief. "Our people are illiterate, so it has been easy to misuse them and convince them certain things are against Islam. The more education we have, the more secure we will be, and the faster we will end our Kalashnikov culture."

Change is often viewed with suspicion in Afghanistan's rural, ethnic Pashtun communities, however. At first, new students said they were greeted with stares and catcalls on the streets of Khost after their leaders donned khaki trousers and dark jackets donated by the local U.S. civil-military program.

But the hostility, they said, has gradually given way to grudging admiration.

"Before we came, it was considered shameful in Khost society to wear [Western] suits. People laughed and shouted at us," said Bacha Azad Noorzai, 22, a medical student who was born in Pakistan but whose parents are from Khost. "Now they realize the university can bring economic progress and knowledge. They are starting to respect us, and our uniforms, too."

The one missing element in this equation is women. Long relegated to lives of illiterate invisibility, women in Khost rarely venture outdoors except to wash laundry in streams, clustering in brilliant scarlet, emerald and electric blue dresses but fleeing like timid jungle birds when men or foreigners approach.

Even during the Eid celebration, when public gathering spots throughout the province were thronged with jubilant crowds of men, there was not a woman to be seen.

In all of Khost province, there is no school for girls beyond seventh grade; none was ever considered necessary. As for female university students in Peshawar, the environment here was deemed so dangerous and hostile that all were transferred to Kabul University in the capital.

Despite the persistence of such traditional taboos, however, Afghan and American officials here hope the benefits of U.S.-aided modernization, the belated establishment of a solid, public-minded provincial administration and the fear of what lies across the border will strengthen Khost's bonds with the U.S.-backed government of Hamid Karzai and wipe out any remaining sympathy for the defeated Taliban.

"Two years ago I was in a Taliban prison and my wife burned my army hat. Two months ago this place was controlled by Bacha Khan and his illiterate thieves. Today we have peace, order and the beginning of progress," said Col. Mohammed Kabir, Khost's security chief.

"Not everything can change quickly, but I am proud to wear my uniform again, and proud that Khost is finally moving into the future."

Kamir Khan, a farmer in the remote eastern city of Khost, holds up the remains of a rocket that landed in his field, next to a U.S. military base.Afghan border guards patrol the disputed frontier with Pakistan, where local leaders say Taliban fighters are hiding.