NAIROBI -- The girls all wore gray sweaters with their stiff green skirts and clunky black shoes, and their short hair was pulled into tight ponytails, a dress code required by their high school to enforce uniformity.

They all moaned about the overcooked school lunch of pounded maize, and they all spoke a slang mixture of Swahili and English known as Sheng, a practice they enforce as rebellious teenagers.

But even though the students at the State House Girls School appeared similar, when their tribal background came up, stereotyped views of one another poured out.

"Kikuyus are the most powerful and the richest tribe," Janet Ndambuki said, looking at her Kikuyu friend, Eva Njeri.

"You do have relatives," chimed in Frida Gacheri, a round-faced 17-year-old from the Meru tribe, raising her eyebrows inquisitively.

When Janet and Eva accused Frida's tribe of being "the worst dressers in all of Kenya," the three girls exploded in laughter.

"Tribalism in Africa, it's still very much there," proclaimed Frida, whose family has often told her she should not marry someone who is not a Meru. "But do we really want to be like our grandparents, quarreling over such tired ways? Aren't we all Kenyans at the end of the day?"

The conversation offers a glimpse of the abiding force of tribalism in Kenya, where, as in most of Africa, it often overrides any sense of nationalism. Political parties form along tribal, not ideological, lines, and opportunities often stem from blood ties. Such allegiances have fueled relentless conflicts across the continent, including those in the Darfur region of Sudan and in Ivory Coast.

Before colonialism, tribal structures served as the equivalents of the modern state, and people turned to their leaders for loans, health care and mediation in domestic disputes. The European colonial powers, arriving in the late 1880s, carved up Africa into new nations that often ignored and sometimes exploited long-standing tribal alliances.

In Kenya, there are 50 tribes, or ethnic groups, with members sharing similar physical traits and cultural traditions, as well as roughly the same language and economic class. Their divisions are dramatized daily in Kenyan soap operas and debated on radio talk shows.

There are signs, however, that among Africa's urban teenagers, the pull of tribalism is waning. Today's youth, called Generation 2, or the second generation since colonial rule ended in 1963, speak the same language, dance to the same Swahili hip-hop beats and laugh at the old tribal stereotypes.

Most of all, they recognize that tribalism has caused many of Africa's problems and they are determined not to repeat the mistakes of their parents.

Yet outside the sturdy iron gates of their schools, young Kenyans are finding a different reality, where tribalism still infuses all aspects of society.

Christopher Khaemba, the principal of Alliance High School, one of the oldest and most prestigious boys' secondary schools in Kenya, said, "If Africa is to go forward, the next generation has to be able to develop national identities rather than tribal loyalties that have wreaked havoc across the continent."

Converging in the Cities

In Nairobi, the capital, the population has more than doubled in the past five years, as peasants have left their increasingly unprofitable fields of coffee and corn and squeezed into tin-roofed working-class slums in hopes of finding a job.

Migration to the cities is occurring across the continent, and while urban life weakens rural traditions and often breeds problems such as high crime rates, it also provides an environment for new ideas. The children of these urban migrants, representing their countries' various tribes, are living and studying side by side.

For the freshman class at State House Girls, speaking their parents' tribal languages has proved a messy and often hurtful teenage experience.

In her dorm room on a recent afternoon, Gloria Olembo, 15, who is from the Luhya tribe, said she felt angry and left out when girls around her spoke in Kikuyu.

"It was like they were passing notes behind my back that I couldn't read," she said. "I started thinking they might be talking and laughing about me."

The next day, one of the girls, Sharon Waringa, said she and her friends later realized they should not have spoken only in Kikuyu.

"It really wasn't right," said Sharon, 14, who has a puff of curly hair and large almond-shaped eyes. "At first we were just playing around. But then we realized that it can sting. I was thinking of my parents and how they used to talk among themselves before I could understand."

Sharing Culture

To lessen tensions over language, Sharon and her friends often speak in Sheng, a dialect born in the slums of Nairobi and spoken by young people who want their own common vocabulary. Sharon says that speaking Sheng is more fun and just far more hip than speaking in the tribal languages, which the girls call "shamby" -- a Sheng word meaning from the shamba or farm, old-fashioned.

Many teachers object to Sheng because they see it as crude and grammatically incorrect. But lately, the dialect has been finding its way into composition papers written by students in Leah Kabue's English literature class.

"It's not like you can apply for a job or take a test using Sheng with your elders," said Kabue, a popular and energetic teacher. Kabue said she hoped her love of teaching African poetry and parables would help bring the girls together without Sheng.

That afternoon, Kabue told her ninth-grade class about her plan to hold an assembly honoring tribal songs.

Moving around the classroom, Kabue said she was disappointed that many teenagers seemed to want to forget their culture and instead adopt a sloppy soup of Swahili and English mixed with Western culture.

"Sheng unites you," she said, "but it frustrates your teacher of English because it's not correct usage.

"If you leave your culture," she added, borrowing a Swahili phrase, "then you are like a slave." Her class repeated the sentence in unison.

The next day, Kabue hosted an oral literature festival in a grassy field near the dorms. She had girls from each tribe form their own group and perform.

"Luos, come to the center, please," she called out. A neat line of girls with colorful African fabric wrapped around their waists started to sing songs about weddings and the hardships of farming, the dangers of malaria and the importance of working hard.

The other tribal groups took their turns, all singing songs with similar messages. The girls clapped each time, even though they couldn't understand each other's parables.

"It is really nice, anyway," Gloria said after her group's turn. "It's a time when everyone can feel included and share their culture."

At the end, though, the girls joined together and performed a hip-hop song in Sheng.

At first, Kabue made a pained face, but then she began to clap along and move her hips to the beat. "Wow, I don't even know those words," she confessed. "It's like they have a whole new language."

Ethnic Balance

The students inside the sprawling stone buildings on the campus of Alliance High and State House Girls wake up each morning at 5:30 and study for four hours every night. They earn among the highest scores on national exams.

But when the students graduate, they, their teachers and their parents worry that they won't find well-paid jobs without tribal connections.

Inside the offices of Alliance High, Khaemba, the principal, leaned back into the cushions of a worn sofa. Members of his Luhya tribe routinely burst through his door and request jobs, he said. Sometimes a parent comes in, asking for a child to be admitted to the school and mentioning some distant tribal tie.

"No one knocks in this place," complained Khaemba, a jovial and frank man with neatly trimmed black hair. "If I am their tribe, I'm going to be expected to give them a job. The stress of the old ways of doing business, I tell you!"

Khaemba, a former math teacher, recalled a time under British rule when only whites were allowed to go to school. Later, he said, only Kikuyus received the best slots in schools. Then, he said, showing a visitor a list of students dating back to the 1940s, other tribes started to be admitted, including his own.

"I tell those who ask that I just can't pick them based on a favor my relative owes them," he said. "It has to be on merit."

His office was decorated with the names of students who have gone on to Harvard and Oxford. "The schools are supposed to be this device to bring equality," he said. "If it weren't for schools, I wouldn't have made it."

The Kenyan teachers union is currently scrutinizing teachers and principals with a view to ethnic balance. In recent years, Khaemba has dedicated a few of his Saturday talks with the students to the issue of tribes and hiring.

"It's a problem we are all dealing with," he said as he sipped milky Kenyan tea.

After accusations that she was hiring too many members of her own tribe for the janitorial staff, the principal at State House Girls, Sarah Ndege, stopped talking about her tribe altogether.

In the school magazine, her biography includes the statement: "She does not wish to indicate where she was born, preferring just to say she's a Kenyan."

"How many more generations will it take for this tribalism stuff to go away?" Ndege asked recently. "I think we need to start somewhere so the young generation just puts it away."

Tugged in Two Directions

At State House Girls School during lunch on a recent day, seniors from different tribes discussed their ambitions and anxieties. They said they felt tugged in two directions: toward the desire to succeed at the job of their choice through grades and seemingly endless standardized tests, and toward the pull of their families to honor tribe and tradition, to go back home, marry and work at whatever job they find for the community's benefit.

The girls shared their ambitions. Eva wants to be a pilot. Janet wants to work in the tourism industry. Frida would like to work in finance. They all worry about their future -- not just about the 70 percent unemployment rate, but also about their access to jobs.

"Hiring based on tribe is very much there," said Maria Atieno, a Luo, who shared a desk with Frida, a Meru. "It's the way people are raised -- your tribe is still the priority. It's bad, but it's life."

"You spend so much time and live with each other in school, hopefully something will change," said Janet, crouched over a physics book. "You can't just give one of your own people jobs because you have power."

In unison, they hummed a hip-hop song called "Bless My Room," by a Kenyan band called Necessary Noise. The lyrics tell the story of the depressing life of poverty for a teenager whose country is torn apart by tribalism and corruption.

"It's like my favorite line in a Nigerian book is, 'It's not what you know, it's who you know,' " said Frida, quoting from "A Man of the People," a 1966 novel by Nigeria's Chinua Achebe. "That really meant something to me. I think that's what we are fighting against."

But what will happen after they graduate, when they meet on the street or perhaps on a job, the friends asked each other.

"Would you offer me the job since I was your desk mate and you know my merits and how hard I studied?" Maria asked. "Or would you give it to a Meru tribes member, who may know your parents?"

The room, usually filled with high-pitched teenage voices, fell silent. Outside, the wind ruffled the banana trees, and construction workers hammered away on a dorm for future students.

"I don't really know what I would do," Frida said, doodling on her math notes with a pencil. "I have to be honest and say I would think about it a lot. But even now, I know it won't be that easy for me to refuse my own people."