In their first debate, Sen. Ed Markey and Rep. Joe Kennedy III were in agreement on most major policy areas, but sparred over who was the right person to occupy Massachusetts' junior Senate seat in the age of President Donald Trump.

“This one counts,” Kennedy said. “For this moment, we have to make sure that we have a United States senator who is giving everything that you have.”

In contrast, Markey called on voters to look at his record in Congress, which includes his work on environmental issues, health care policy and gun control legislation — where he recently helped pass a budget amendment that gave $25 million to the CDC to fund gun research.

The debate, hosted by WGBH News, touched on a variety of issues from immigration to housing to healthcare to the environment. On many of the issues, the candidates were largely in agreement. Both are co-sponsors of Medicare for All legislation and both support the Green New Deal, of which Markey is a co-author along with New York Rep. Alexandria Ocasio-Cortez.

One area where the candidates disagreed was on foreign policy. When the debate turned to the war in Afghanistan, Kennedy appeared to be calling for an immediate troop withdrawal. Markey, while agreeing with Kennedy on the need to bring down the American presence in Afghanistan, cautioned that a sharp drawback of troops could lead to instability in the nation.

“When I visit Afghanistan I can see the incredible tension still on the streets of that country,” Markey said. “Draw down the troops, do it as much as you can while you’re guaranteeing that any agreement is in fact working.”

Kennedy stopped short of calling the 19-year war a complete failure, but he did cite the lack of a clear goal as the primary reason for pulling back troops.

“We still have no idea after 20 years what our mission is, what success looks like, how long it’s going to take or the burden we are putting on our men and women in our uniforms and our families,” Kennedy said. “Yes, we need to make sure we are protecting innocent civilians in Afghanistan, but we have been doing that for 20 years at grave cost.”

In one of the few moments of clear disagreement between the two, Kennedy criticized Markey for voting present on a resolution in the Senate Foreign Relations Committee that would have authorized the use of force against Syrian dictator Bashar Al-Assad in 2013. At the time, Kennedy was a member of Congress and not given the chance to vote on a similar resolution.

“Not no, not yes, on a matter of war and peace, but present,” Kennedy said. “I think that speaks for itself.”

Markey defended his decision, and said he did not want to rush to judgment. He said that when he voted present there was still insufficient information provided to him and the committee to make a fair decision on whether to engage in Syria.

“There was a rush to judgment. There was an attempt to force a vote without complete information being given to the committee,” Markey said. “I said, 'I’m waiting until I get everything I need to know whether or not we should be bombing Syria or bombing Assad for 60 days.'”

In another tense exchange, Markey and Kennedy diverged on whether progressive political action committees should be allowed to spend in Massachusetts elections. Prior to the debate, Kennedy had called on Markey to sign a “People’s Pledge” to prevent outside money from entering the senate race. Kennedy’s initial request came days after the group Environment Massachusetts announced they would work with the Environment America Action Fund to spend $5 million dollars in support of Markey.

“Dark money is dark money. ... Massachusetts walks the walk when it comes to progressive values. We need to do it now,” Kennedy said. “You open the door to this, you open the door to an absolute landslide of money coming in to distort the electoral framework we have been so proud to be able to keep alive.”

Markey disagreed. He took issue with the characterization of environmental groups as dark money, and said that states like Massachusetts should allow activist groups to participate in elections, so long as they disclose their funding sources.

“We should not silence these progressive groups. We should encourage them. We should celebrate their desire in the era of Donald Trump in the White House trying to destroy every one of our values,” Markey said. “If they want to come into this debate, speak positively, disclose their funding sources, we should welcome and celebrate it, but keep out the dark money and keep out the negative voices.”

And though Kennedy accused Markey of creating a slippery slope that could eventually allow fossil fuel companies to “open a spigot and flood the airwaves with scare tactics,” the congressman refused to answer whether he would divest his stock portfolio from more than $1 million worth of fossil fuel stocks. Instead, Kennedy said that his votes have never been influenced by the companies in his stock portfolio.

“There is not a single vote that anybody can point to that shows investment holdings that I’ve long held have influenced my vote once,” Kennedy said. “The idea that those holdings have influenced my vote at all? You can’t find it.”

Markey doubled down on his environmental record when confronted about donations he had accepted from the investment firm BlackRock, which among other fossil fuel investments has invested in Algonquin Gas, a company that has ties to the Weymouth compressor project, He noted that he has been an active opponent of the project.

In addition to the Green New Deal, Markey touted his legislative record on the environment, which earned him a perfect score from the League of Conservation Voters in 2018. Overall, Markey called on voters to look at his storied career in Congress, which has included his work on gun control legislation — and healthcare.

“I will lead on the Green New Deal and get it passed in the next congress. I will lead on the strongest possible gun legislation that can pass and make it the law of the land,” Markey said. “I've already been successful on passing legislation in those areas and I will continue this effort.”

When the conversation turned towards Medicare for All’s controversial provision of phasing out private insurance, Markey answered that he is in favor of phasing out private insurance, so long as it is done in a timely and non-disruptive manner. Kennedy, however, refused to answer until pressed by moderator Jim Braude. Kennedy eventually said he thought quality health care could be provided without private insurance.

“I think we need to make sure we provide access to care that we need and I think we can do that without access to private insurance,” Kennedy said.

In his final comment of the evening, Kennedy said that while crafting legislation is important, it is only one aspect of the job. In an indirect critique of Markey, who has crafted a reputation as a low-key senator, Kennedy said that what is needed in 2020 and beyond is a senator who will be a more powerful presence in the senate.

“Yes filing the right legislation and voting the right way is a critical part of the job, but if there's one less from today's Washington, D.C. it’s that this is all about power,” Kennedy said. “And if you are serious about putting the people and the causes that we care about first you got to go out there and you got to take it,”