<?xml version="1.0" encoding="us-ascii"?><InstanceReport xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><Version>2.4.0.8</Version><ReportLongName>123 - Disclosure - Commitments and contingencies</ReportLongName><DisplayLabelColumn>true</DisplayLabelColumn><ShowElementNames>false</ShowElementNames><RoundingOption /><HasEmbeddedReports>false</HasEmbeddedReports><Columns><Column FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><CurrencyCode /><FootnoteIndexer /><hasSegments>false</hasSegments><hasScenarios>false</hasScenarios><MCU><KeyName /><CurrencySymbol /><contextRef><ContextID>eol_PE715633--1310-Q0007_STD_181_20130630_0</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001369786</EntityValue><PeriodDisplayName /><PeriodType>duration</PeriodType><PeriodStartDate>2013-01-01T00:00:00</PeriodStartDate><PeriodEndDate>2013-06-30T00:00:00</PeriodEndDate><Segments /><Scenarios /></contextRef><UPS /><CurrencyCode /><OriginalCurrencyCode /></MCU><CurrencySymbol /><Labels><Label Key="CalendarSupplement" Id="0" Label="6 Months Ended" /><Label Key="Calendar" Id="1" Label="Jun. 30, 2013" /></Labels></Column></Columns><Rows><Row FlagID="0"><Id>1</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>4</Level><ElementName>us-gaap_CommitmentsAndContingenciesDisclosureTextBlock</ElementName><ElementPrefix>us-gaap_</ElementPrefix><IsBaseElement>true</IsBaseElement><BalanceType>na</BalanceType><PeriodType>duration</PeriodType><IsReportTitle>false</IsReportTitle><IsSegmentTitle>false</IsSegmentTitle><IsCalendarTitle>false</IsCalendarTitle><IsEquityPrevioslyReportedAsRow>false</IsEquityPrevioslyReportedAsRow><IsEquityAdjustmentRow>false</IsEquityAdjustmentRow><IsBeginningBalance>false</IsBeginningBalance><IsEndingBalance>false</IsEndingBalance><IsReverseSign>false</IsReverseSign><PreferredLabelRole>terseLabel</PreferredLabelRole><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="eol_PE715633--1310-Q0007_STD_181_20130630_0" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;div&gt;
&lt;p style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px"&gt;&lt;font style="FONT-FAMILY: Times New Roman" size="2"&gt;&lt;b&gt;Note
17.&amp;#xA0;Commitments and contingencies:&lt;/b&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN-TOP: 6px; MARGIN-BOTTOM: 0px"&gt;&lt;font style="FONT-FAMILY: Times New Roman" size="2"&gt;&lt;i&gt;Litigation&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="MARGIN-TOP: 6px; MARGIN-BOTTOM: 0px"&gt;&lt;font style="FONT-FAMILY: Times New Roman" size="2"&gt;From time to time, we are
subject to claims and litigation arising in the ordinary course of
business. These claims may include assertions that our products
infringe existing patents and claims that the use of our products
has caused personal injuries. We intend to vigorously defend any
such litigation that may arise under all defenses that would be
available to us.&lt;/font&gt;&lt;/p&gt;
&lt;p style="PADDING-BOTTOM: 0px; MARGIN-TOP: 18px; MARGIN-BOTTOM: 0px"&gt;
&lt;font style="FONT-FAMILY: Times New Roman" size="2"&gt;&lt;i&gt;Zoledronic
Acid (Generic versions of Zometa&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
and Reclast&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;).&lt;/i&gt;&lt;/font&gt;&lt;/p&gt;
&lt;p style="PADDING-BOTTOM: 0px; MARGIN-TOP: 6px; MARGIN-BOTTOM: 0px"&gt;
&lt;font style="FONT-FAMILY: Times New Roman" size="2"&gt;On
February&amp;#xA0;20, 2013, Novartis Pharmaceuticals Corporation
(&amp;#x201C;Novartis&amp;#x201D;) sued the Company and several other
defendants in the United States District Court for the District of
New Jersey, alleging, among other things, that sales of the
Company&amp;#x2019;s (i)&amp;#xA0;zoledronic acid premix bag
(4mg/100ml)&amp;#xA0;supplied to the Company by ACS Dobfar Info S.A.
(&amp;#x201C;Info&amp;#x201D;), a generic version of Novartis&amp;#x2019;
Zometa&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
ready to use bottle would infringe U.S. Patent No.&amp;#xA0;7,932,241
(the &amp;#x201C;241&amp;#xA0;Patent&amp;#x201D;) and U.S. Patent
No.&amp;#xA0;8,324,189 (the &amp;#x201C;189&amp;#xA0;Patent&amp;#x201D;);
(ii)&amp;#xA0;zoledronic acid premix bag (5mg/100ml)&amp;#xA0;also supplied
ot us by Info, a generic version of Novartis&amp;#x2019;
Reclast&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
ready to use bottle would infringe U.S. Patent No.&amp;#xA0;8,052,987
and the 241 Patent (Novartis Pharmaceuticals Corporation v.
Actavis, LLC, et. al., Case No.&amp;#xA0;13-cv-1028), and
(iii)&amp;#xA0;zoledronc acid vial (4mg/5ml), a generic version of
Novartis&amp;#x2019; Zometa&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
vial supplied to the Company by Actavis, would infringe the 189
Patent. On March&amp;#xA0;1, 2013, the District Court denied
Novartis&amp;#x2019; request for a temporary restraining order against
the Company and the other defendants, including Actavis and Info.
On March&amp;#xA0;6, 2013, the Company began selling Actavis&amp;#x2019;
zoledronic acid vial, the generic version of Zometa&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;.
The Company believes it has substantial meritorious defenses to the
case. The Company has sold and is continuing to sell Actavis&amp;#x2019;
zoledronic acid vial, and intends to sell Info&amp;#x2019;s zoledronic
acid premix bag versions of Zometa&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
and Reclast&lt;font style="FONT-FAMILY: Times New Roman" size="1"&gt;&lt;sup style="POSITION: relative; BOTTOM: 0.8ex; VERTICAL-ALIGN: baseline"&gt;&amp;#xAE;&lt;/sup&gt;&lt;/font&gt;
upon FDA approval of those products. Therefore, a final
determination that one of the patents is valid and infringed could
have an adverse effect on the Company&amp;#x2019;s business, results of
operations, financial condition and cash flows.&lt;/font&gt;&lt;/p&gt;
&lt;/div&gt;</NonNumbericText><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>nonnum:textBlockItemType</ElementDataType><SimpleDataType>na</SimpleDataType><ElementDefenition>The entire disclosure for commitments and contingencies.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 210

 -SubTopic 10

 -Section S99

 -Paragraph 1

 -Subparagraph (SX 210.5-02.25)

 -URI http://asc.fasb.org/extlink&amp;oid=6877327&amp;loc=d3e13212-122682



Reference 2: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 825

 -SubTopic 20

 -Section 50

 -Paragraph 1

 -URI http://asc.fasb.org/extlink&amp;oid=6449706&amp;loc=d3e16207-108621



Reference 3: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 460

 -SubTopic 10

 -Section 50

 -Paragraph 8

 -URI http://asc.fasb.org/extlink&amp;oid=6398077&amp;loc=d3e12565-110249



Reference 4: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 450

 -SubTopic 20

 -Section 50

 -Paragraph 4

 -URI http://asc.fasb.org/extlink&amp;oid=25496072&amp;loc=d3e14435-108349



Reference 5: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 440

 -SubTopic 10

 -Section 50

 -Paragraph 2

 -URI http://asc.fasb.org/extlink&amp;oid=6394976&amp;loc=d3e25287-109308



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Commitments and contingencies</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>Commitments and contingencies</ReportName><MonetaryRoundingLevel>UnKnown</MonetaryRoundingLevel><SharesRoundingLevel>UnKnown</SharesRoundingLevel><PerShareRoundingLevel>UnKnown</PerShareRoundingLevel><ExchangeRateRoundingLevel>UnKnown</ExchangeRateRoundingLevel><HasCustomUnits>true</HasCustomUnits><IsEmbedReport>false</IsEmbedReport><IsMultiCurrency>false</IsMultiCurrency><ReportType>Sheet</ReportType><RoleURI>http://www.sagentpharma.com/taxonomy/role/NotesToFinancialStatementsCommitmentsAndContingenciesDisclosureTextBlock</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>1</NumberOfRows></InstanceReport>
