Hordes of schoolchildren in Technicolor T-shirts and matching caps swirl through Guimaraes, giggling and chattering as chaperones usher them toward a gravel path for a history lesson. One end of the path leads to a windowless granite fortress atop a grassy hill, the other end to the city's compact, medieval core. All around is hallowed ground, the cradle of Portugal.

To an outsider, this small country's legacy as a maritime power lingers in the monuments and filigreed architecture of Lisbon and Porto, where waterfront plazas signify its once-vast colonial holdings. But to every Portuguese child, the story began inland, hundreds of years before the golden age, with the birth of the first king.

Born in Guimaraes in 1109, Afonso Henriques exhibited a precocious, if rebellious, nature by defeating his mother's forces in battle and taking power when he was only 19. He then spent more than 50 years taking much of the country back from the Moors, spawning a legend as ingrained as the one about George Washington and the cherry tree in the United States. Tall tales say Afonso I was almost 7 feet tall and that it took 10 men to carry his sword. He had light hair and eyes, and he was electrically charismatic.

"Personal marketing worked in those days, as well," my guide, Vitor Marques, says as grade schoolers huddle for a group picture around a statue of an armored Afonso. "You can imagine him being in front of the troops. It made an impression that was different. And he wasn't a king of palaces. He was a king of conquering, of the battlefield, all his life."

Nowadays, Guimaraes' lasting charm is just as likely to draw day-trippers from Porto, a short train ride away. One morning, Marques and I set off in search of the modern and the medieval.

We began under crystal-blue skies at the statue, triumphant in its position at the foot of the castle that informally bears Afonso's name, though he never lived there.

The imposing fortress is all muscle, a bulky collection of solid, granite towers. Most of what remains was added in the 14th century, and now it's nearly hollow inside but for a couple of walkways sliced through the truck-size boulders that form the foundation. Up a wooden staircase to the top of the crenellated walls, a stellar view includes terraced vineyards cut into the rolling countryside. The grapes will become vinho verde, the zippy white wine that is one of Portugal's biggest exports.

A hundred yards down the path is a spare Romanesque chapel that houses the purported font used to baptize Afonso. The humble vessel looks like a giant chalice, marked by a tablet in Latin and secure behind wrought-iron bars. Next door is the 15th-century Palace of the Dukes of Braganza, built by an illegitimate son of one of Afonso's heirs. It's even bigger than the castle, with rounded turrets at the corners.

The path gives way to cobblestones as we pass a former convent and other religious structures that have been turned into government buildings and social-service agencies. The street, Rua de Santa Maria, is the oldest in town. It narrows as we enter the pedestrian-only center, and Marques' words echo off the stone buildings.

"Nobody designs a street like this," he says. "It just grows organically, with the buildings bending over and all of them kind of leaning against each other."

The street spills into the picturesque plaza Sao Tiago (St. James), which could double as the market square in an English village. Wood-frame buildings ringing the plaza are painted mostly brown and white, lacking the tiled facades that are so common throughout Portugal. Many of these buildings predate the time when tiles became fashionable, and, because it's a UNESCO World Heritage Site, any changes are severely restricted.

Marques points out that there are no TV antennas or other modern eyesores visible on the terra-cotta tile roofs. The whole town, though, is wired for free WiFi service. The plaza is filled with patio tables and chairs, identical except for the bright colors that identify which restaurant they belong to.

We stop at Casa Costinhas, a cafe owned by one of a handful of families with the original recipe for the torta de Guimaraes. Two great-aunts of the owner were once servants to the nuns in the convent up the road, where the recipe originated, Marques says. The clam-shaped puff pastry is made with loads of eggs and sugar, then stuffed with almonds and spaghetti squash. It's unique, sort of like a pumpkin pie croissant, and deeply satisfying.

Continuing on, I notice clamshells carved into the granite pavers underfoot. They're a sign that we're walking on a path pilgrims took in the Middle Ages to reach the Spanish town of Santiago de Compostela. But it's not the "Camino" immortalized in the Paul Coelho book and Martin Sheen movie. It's an alternative way, coming from the south, which Marques says he completed a few years back - eight days and 135 miles from Guimaraes. Apparently, the real camino was always any path between your house and the cathedral in Santiago, but people tended to follow the most popular route because it was safest.

Sidewalk cafes start filling up for lunch, with a young crowd sipping beers in the sunshine, many of them students from the University of Minho, which has its engineering campus there. For formal events, the students still wear long black capes, a la Harry Potter. The students at the cafe tables are dressed down for the day. The school contributes to a youthful atmosphere in town and to more restaurants, bars, and DJ nights than one might expect in a city of 160,000.

Nearby is another statue of Afonso, a modern, cubist version dedicated at the turn of the millennium. Behind it, the castle and Duke's Palace are visible on the hill above town, a reminder that Afonso is watching over everyone. In case he ever slips from mind, there are also a soccer stadium, boulevard, school, bakery, restaurant, and a host of other businesses bearing his name.

Marques says that to the Portuguese, Afonso isn't some abstract figure from the distant past. A university study a few years ago asked young kids around the country: Who is the oldest person you know? In Guimaraes, rather than a grandparent or a neighbor, one of the most common answers was Afonso.

"You can see the presence of the figure is still strong," Marques says next to a Gothic gazebo that commemorates a battle victory by Afonso's great-great-grandson. "Because even kids, they say, 'Well, it's Afonso Henriques because he's a thousand years old.' "