The hook for it came, as these things sometimes do, during a class in using concealed handguns. Ms. Lambert, who lives in Texas, was inspired to take the class after she met a successful lawyer who carried a pistol in her purse. ''She was the last one you'd expect, a pretty little blonde,'' said Ms. Lambert in a telephone interview from Michigan, where she was touring with Dierks Bentley.

Ms. Lambert took the class last summer; her father, a former police officer and private investigator, was her classmate. (He outshot her, but she beat him on the written test.) While daydreaming during a lecture, she came up with the lyric: ''I'm gonna show him what a little girl's made of/Gunpowder and lead/His fist is big but my gun's bigger/He'll find out when I pull the trigger.''

Raucousness is the dominant mode on ''Crazy Ex-Girlfriend,'' Ms. Lambert's second major-label album. It builds on the raw side she displayed so effectively on her 2005 debut, ''Kerosene,'' which has been certified platinum and which established her as both a critical and fan favorite, one of country music's most promising young stars. Backed by ragged, loud guitar work and production that is full but not slick, Ms. Lambert sounds like a brash rabble-rouser, an emotionally insightful spark plug. And in the context of the current country mainstream, safe as it is, she sounds very much like an outsider.

Ms. Lambert, 23, cites the usual outlaw influences -- Waylon Jennings, Merle Haggard -- as well as the well-regarded singer-songwriters Steve Earle, Buddy Miller, Jerry Jeff Walker and Guy Clark. In essence, Ms. Lambert is an alt-country singer operating covertly in the mainstream. ''Dwight Yoakam, the Dixie Chicks -- I think there's a way to be really cool and mainstream, too,'' she said.

Part of her success can be attributed to the nine weeks she spent as a contestant on the 2003 debut season of the USA Network's ''Nashville Star,'' an ''American Idol'' for country music. ''It was a vehicle that saved me a couple years of honky-tonks,'' Ms. Lambert said.

She placed third and scored a record deal; the album that followed, ''Kerosene,'' remains the best-selling, and best, album to come from a ''Nashville Star'' competitor. It made its debut at No. 1 on the Billboard country album chart, a surprise given that she had not yet had a single in the Top 20. And it was certified platinum without significant support from country radio: none of the four singles from the album cracked the Top 10 of the Billboard country singles chart, which is heavily determined by radio play.

''She's a little harder-edged than what you're going to hear from most female artists in this format,'' said Lon Helton, publisher of the trade publication Country Aircheck. ''It might be closer to what some men sing, and to radio programmers it might make it a hair uncomfortable.''

Ms. Lambert is perhaps a touch too cool for a genre that, despite several outlaw movements, has continued to assert itself as hidebound and musically conservative. She says the country singer Gretchen Wilson opened the door for her, thanks to Ms. Wilson's debut single: the ragged working-class anthem ''Redneck Woman,'' ahuge hit in 2004.

''Before her there was no hope,'' Ms Lambert said. ''People were like, 'You're not coming in here singing that grimy song!' ''

But grimy songs have served Ms. Lambert well. The title track of ''Kerosene,'' an aggressive, rock-oriented breakup song, was the album's most successful radio single. Ms. Lambert had wanted it released first, but her label opted to release it third. She is facing a similar struggle with ''Crazy Ex-Girlfriend.'' ''I wouldn't have picked 'Famous in a Small Town,' '' she says of the wistful and plain first single. Indeed, it is a far cry from some of this album's high points -- the saucy, aggressive title track or ''Down,'' which flirts with bluegrass and hard rock. Even ''More Like Her,'' the album's softest track, is entrancingly dark.

Ms. Lambert has writing credit on 11 of her debut album's 12 songs and 8 of the 11 songs on ''Crazy Ex-Girlfriend.'' She has been finding the process tougher when coupled with the demands of the road, though.

''I used to sit down and just write. Now I don't even remember the last time I finished a song,'' she said. ''I see what happens to artists when they stop writing, and it really bothers me. I can feel it happening to me, and it's frustrating.''

She honed her songwriting chops long before she appeared on ''Nashville Star,'' practicing her craft while she still lived with her parents in Lindale, a town of about 3,000 in the eastern part of Texas. (She now lives in a house close to her parents.) ''There's a saying, 'Raise your kids according to their bend,' '' she said. ''And my mom did just that.'' As a child, Ms. Lambert gravitated toward the piano and later the guitar. When she didn't excel in scholastics, her mother successfully petitioned to reinstate the school choir so her daughter could follow her passion.

Ms. Lambert's parents, who now run her merchandise operation, were private investigators who were on the team that worked for Paula Jones in her lawsuit against President Bill Clinton. Talk at the dinner table about infidelities was frank, giving Ms. Lambert plenty of grist for her done-wrong tales. ''I wrote a lot of my songs at 17,'' she said, recalling those talks. ''So no, I haven't lived all that life.''

But she credits her unsheltered upbringing with helping her cope with stardom at a young age. ''I am a really good judge of character,'' she said. ''I'm skeptical almost to a fault. When things go awry and I'm the boss, I have the tools to sit down and think logically.''

Ms. Lambert raised eyebrows, though, when reports suggested she was dating a fellow country star, Blake Shelton, before his divorce was final. They met while performing a duet of ''You're the Reason God Made Oklahoma'' for a 2005 special on Country Music Television. Mr. Shelton, seven years her senior, is known for putting a wry twist on gentleman country ballads (his most recent album is ''Pure BS''); in a sense, they're both Nashville skeptics working within the system. And minor gossip aside, they're a very low-key couple, rarely flaunting their relationship in public. ''We're not trying to be the next Faith and Tim,'' Ms. Lambert said, referring to the married country superstars Faith Hill and Tim McGraw.

Still, given her rising fame, she is trying to learn to project a bit bigger. ''I never considered myself a performer,'' said Ms. Lambert, who started out playing small acoustic gigs in Texas honky-tonks. She's been working on her stage skills, adjusting her live show to better suit the larger concerts she's now playing -- even if she's not headlining yet.

''I've been getting into live DVDs a lot lately,'' she said. ''Steve Earle at 'Austin City Limits.' I love the Band, 'The Last Waltz.' And 'Beyonc?Live at Wembley.' The charisma and the confidence -- she's the ultimate diva. I'm trying to take little bits from that for my live show.''

So maybe she's not so ''alt'' after all. ''When people I thought were really cool started telling me 'I like your record,' I was like, 'Oh gosh, oh gosh. I'm not going to be popular,' '' she said with mock fear. ''And I want to be mainstream. I don't do anything else in life, and I want to be doing this forever.''

Photo: Miranda Lambert in concert last year with the guitarists Aden Bubeck, left, and Alex Weeden. She came up with lyrics for her song ''Gunpowder & Lead,'' from her new album, ''Crazy Ex-Girlfriend,'' while in a handgun class. (Photo by James Minchin)