The United States, Britain and France have repeatedly accused President Bashar al-Assad's forces of carrying out chlorine gas attacks with barrel bombs dropped from helicopters.
The three countries argue that only the Syrian regime has helicopters. But Russia maintains there is no solid proof that Damascus is behind the attacks.
Both Russia and the United States, divided over the war since it broke out, welcomed the resolution.
"We need to bring the same unity to urgently find a political solution," US ambassador Samantha Power said, adding the resolution "sends a clear and powerful message."
In a tweet, she called the probe a necessary step toward "eventual accountability."
Russian ambassador Vitaly Churkin said the resolution was "a good example of political will, of the will to cooperate and of perseverance to come up with a good product."
The investigative panel will be given "full access" to all locations in Syria and allowed to interview witnesses and collect materials, according to the text of the resolution.
It mandates the panel to "identify to the greatest extent feasible individuals, entities, groups or governments who were perpetrators, organizers, sponsors or otherwise involved in the use of chemicals as weapons" in Syria.
UN Secretary-General Ban Ki-moon is tasked with assembling a team within 20 days, working with the Organization for the Prohibition of Chemical Weapons (OPCW), which is based in The Hague.
The panel would present its first findings to the council 90 days after it begins its work, which would be for a duration of one year.
Questions remain however over whether panel members will be able to travel to sites in a country where war is raging and gain evidence of chlorine attacks that would allow them to assign blame.
Getting the panel up and running will require several steps, each of which must be approved by the Security Council, giving Russia the opportunity to stonewall the investigation down the line, diplomats said.
Ban said the on-site probe will be an "extremely challenging mission" because of the dangerous security situation. Ban called on all both Syria's rebel forces and government to provide full cooperation.
"Holding the perpetrators of the toxic chemical attacks accountable may hopefully alleviate the prolonged suffering of the Syrian people," Ban said in a statement.
Syria's UN ambassador Bashar Jaafari said his country's army "has never used and will never use chemical weapons."
He said extremist groups linked to al-Qaeda have done so, and he questioned the neutrality of previous on-the-ground probes by the UN and the OPCW.
- Russian shift -
Pressure has been mounting on the Security Council to take action in Syria, where the war is now in its fifth year. It tops the UN's list of humanitarian crises.
Russian support for the probe is seen by some western diplomats as a shift by Moscow, which has repeatedly shielded the Assad regime at the United Nations.
"There is a change of tone," one Council diplomat said this week, while cautioning: "I don't want to overstate it."
Diplomats are separately working on a council statement backing a new push for UN peace talks that could yield a plan for a transition that the West insists must lead to Assad's exit from power.
Discussions are inching forward on a new tougher UN measure to ban the use of barrel bombs, building on resolutions that have condemned the practice.
Syria agreed to a US-Russia plan to dismantle its chemical weapons network and join an international treaty banning their use following a 2013 sarin attack on a Damascus suburb that sparked a global outcry.
The United States threatened military action against Damascus over the attack, but backed down and instead worked with Russia to pursue the chemical disarmament agreement.
A total of 1,300 metric tonnes of chemical stockpiles have been removed from Syria under the deal.
But rights groups and Syrian doctors have since come forward with accounts of dozens of chlorine gas attacks that have in particular targeted Idlib province.