Thirteen votes. That’s all that separates Prince George’s County Council candidates Doyle L. Niemann and Deni Taveras after a hard-fought primary election that pitted a savvy newcomer against a seasoned political hand.

“I haven’t seen it this close in all the years I’ve been doing this,” said Prince George’s Election Director Alisha Alexander, who has overseen county elections for a decade. The outcome of Tuesday’s Democratic primary will probably hinge on about 122 provisional ballots, which should be counted starting Wednesday.

The tightness of the race illustrates the power of grass-roots politics and retail campaigning, especially in a fast-changing council district with thousands of newly recruited Hispanic voters.

District 2 includes the inside-the-Beltway towns of Hyattsville, Langley Park, Lewisdale, Chillum and Adelphi. Niemann, 67, has represented most of those communities for decades, as a state delegate in Annapolis since 2002 and on the county school board and the Mount Ranier city council before that. He began the council race confident that the voters would stand by him again.

“I went after anyone with a history of voting,” using mailers, e-mail newsletters, robo-calls and yard signs, Niemann said. He outlined a plan to increase job growth, stimulate economic development and improve schools.

Civic association leaders helped Niemann, and he won the endorsement of police and teachers unions, environmental groups, The Washington Post and other newspapers. He hired bilingual campaign workers to communicate with Spanish-speaking voters and sought support from a group of Hispanic church leaders who had grown disenchanted with outgoing District 2 representative William A. Campos, the first Latino to serve on the council.

“I made a commitment to bring [Latinos] into the political process in ways that haven’t happened in the past,” Niemann said.

Opponents, however, say Niemann may have underestimated the value of venturing out into the broader Hispanic community, and Taveras’s ability to penetrate it.

Taveras built a campaign rooted in her outgoing personality and flush with cash, much of it from a political action committee that also supported Campos, who is running for the House of Delegates, and state Sen. Victor Ramirez (D-Prince George’s), for whom Taveras used to work. She was endorsed by County Executive Rushern L. Baker III (D) and Del. Joseline Peña-Melnyk (D-Prince George’s).

At one point, Taveras, 41, had three teams of up to 160 people knocking on doors and waving signs on street corners. She estimated that her campaign reached about 17,000 potential constituents.

“It’s clearly that personal touch — regardless of whether there was substance to it — that made a huge difference,” Niemann said. “It is a reflection of the power of showing up to people’s doors.”

But Taveras, who is Dominican American and bilingual, did more than ask for votes.

“I sat down in their living rooms, I ate their food, and I drank their water if they offered,” Taveras said. “I asked them, ‘Tell me what you think I need to do.’ I developed my entire platform based on what people told me.”

Two or three times a week, Taveras campaigned outside the West Hyattsville Metro station, meeting crowds of voters heading to and from work. By the end, she recognized most of the faces, had met people’s families and could recite their concerns.

When the votes were counted on Election Day, Niemann had 2,324, six more than Taveras’s 2,318. Tallying absentee ballots on Thursday brought the count to 2,378 for Niemann, 2,365 for Taveras.

Although votes cannot be tracked by ethnicity, Taveras said she believes it was a surge of newly registered Latino voters that enabled her to close the gap.

CASA in Action, the voter registration arm of the immigrant advocacy group, launched a Latino engagement program in Prince George’s in 2010, mining publicly available databases to identify unregistered voters who the group believed were Latino. CASA sent people to knock on doors to check whether members of particular households were eligible to vote and, if so, whether they were registered. If not, they gave information for how to do so.

The organization said the number of Democratic registered voters with Hispanic surnames in Prince George’s grew by nearly 50 percent between 2010 and 2014 — from just under 11,000 to more than 16,000.

“It also really helps to have candidates here who believe that mobilizing those voters is a key to their success,” CASA lobbyist Kim Propeack said.

In the three District 2 precincts with the most dense Latino population, the number of registered Democrats identified by CASA as Hispanic has more than doubled. Taveras carried all three. She spent much of Tuesday outside Nicholas Orem Middle School in Hyattsville, the polling station for one of the precincts, and won there by about 45 votes.

Ramirez, the first Latino state senator in Maryland, said Taveras’s outreach to Hispanic voters was key. “You got to give folks a reason to vote who normally don’t vote,” he said. “She motivated many different kinds of people because people connected with her.”