<?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>2122100 - Disclosure - Repurchase agreement</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>D2013Q2YTD</ContextID><EntitySchema>http://www.sec.gov/CIK</EntitySchema><EntityValue>0001555039</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>true</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>1</Level><ElementName>us-gaap_DebtDisclosureAbstract</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><FootnoteIndexer /><Cells><Cell FlagID="0" ContextID="" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText /><FootnoteIndexer /><CurrencyCode /><CurrencySymbol /><IsIndependantCurrency>false</IsIndependantCurrency><ShowCurrencySymbol>false</ShowCurrencySymbol><DisplayDateInUSFormat>false</DisplayDateInUSFormat></Cell></Cells><ElementDataType>xbrli:stringItemType</ElementDataType><SimpleDataType>string</SimpleDataType><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Debt Disclosure [Abstract]</Label></Row><Row FlagID="0"><Id>2</Id><IsAbstractGroupTitle>false</IsAbstractGroupTitle><LabelSeparator>

</LabelSeparator><Level>2</Level><ElementName>us-gaap_DebtDisclosureTextBlock</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="D2013Q2YTD" UnitID=""><Id>1</Id><IsNumeric>false</IsNumeric><IsRatio>false</IsRatio><DisplayZeroAsNone>false</DisplayZeroAsNone><NumericAmount>0</NumericAmount><RoundedNumericAmount>0</RoundedNumericAmount><NonNumbericText>&lt;div style="font-family:Times New Roman;font-size:10pt;"&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;font-weight:bold;"&gt;&lt;/font&gt;&lt;font style="font-family:Times New Roman;font-size:10pt;color:#000000;font-weight:bold;text-decoration:none;"&gt;Repurchase agreement&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;font-weight:bold;"&gt; &lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;&lt;br clear="none"/&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;On March&amp;#160;22, 2013, our operating partnership entered into a master repurchase agreement with a major financial institution. The purpose of the repurchase agreement is to finance the purchase and beneficial ownership of mortgage loans and REO properties in our portfolio. We have effective control of the assets associated with this agreement and therefore have concluded this is a financing arrangement. The maximum funding amount available to us under the repurchase agreement is &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$100.0 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;, subject to certain sublimits. As of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;June&amp;#160;30, 2013&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;, an aggregate of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$0.5 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; was outstanding under the repurchase agreement which was collateralized by mortgage loans and real estate owned with a carrying value of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;$1.0 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;. As of June 30, 2013 the cost of funds for amounts borrowed under the repurchase agreement was approximately &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;3.5%&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;. As of &lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;color:#000000;text-decoration:none;"&gt;July&amp;#160;18, 2013&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;, an aggregate of &lt;/font&gt;&lt;font style="font-family:Times New Roman;font-size:10pt;color:#000000;font-style:normal;font-weight:normal;text-decoration:none;"&gt;$0.5 million&lt;/font&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt; was outstanding under the repurchase agreement. The obligations under the repurchase agreement are fully guaranteed by the Company. The repurchase agreement matures on March&amp;#160;21, 2014.&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;&lt;br clear="none"/&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;Under the terms of the repurchase agreement, as collateral for the funds we draw thereunder, the operating partnership will sell to the lender equity interests in our Delaware statutory trust subsidiary that owns the underlying mortgage assets on our behalf. In the event the lender determines the value of the collateral has decreased, it has the right to initiate a margin call and require us to post additional collateral or to repay a portion of the outstanding borrowings. The price paid by the lender for each underlying mortgage asset we finance under the repurchase agreement is based on a percentage of the market value of the underlying mortgage asset and depends on its delinquency status. With respect to funds drawn under the repurchase agreement, the operating partnership is required to pay the lender interest at the lender's cost of funds plus a spread calculated based on the type of applicable underlying mortgage assets collateralizing the funding, as well as certain other customary fees, administrative costs and expenses to maintain and administer the repurchase agreement.&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;&lt;br clear="none"/&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;The repurchase agreement requires us to maintain various financial and other covenants, including maintaining a minimum adjusted tangible net worth, a maximum ratio of indebtedness to adjusted tangible net worth and specified levels of unrestricted cash as well as restrictions on net losses in excess of specified amounts.&amp;#160;In addition, the repurchase agreement contains customary events of default. We are restricted by the terms of our repurchase agreement from paying dividends greater than our REIT taxable income in a calendar year. &lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;&lt;br clear="none"/&gt;&lt;/font&gt;&lt;/div&gt;&lt;div style="line-height:120%;text-align:left;font-size:10pt;"&gt;&lt;font style="font-family:inherit;font-size:10pt;"&gt;We are currently in compliance with the covenants and other requirements with respect to the repurchase agreement. We monitor our banking partner's ability to perform under the repurchase agreement and have concluded there is currently no reason to doubt that it will continue to perform under the repurchase agreement as contractually obligated.&lt;/font&gt;&lt;/div&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 information about short-term and long-term debt arrangements, which includes amounts of borrowings under each line of credit, note payable, commercial paper issue, bonds indenture, debenture issue, own-share lending arrangements and any other contractual agreement to repay funds, and about the underlying arrangements, rationale for a classification as long-term, including repayment terms, interest rates, collateral provided, restrictions on use of assets and activities, whether or not in compliance with debt covenants, and other matters important to users of the financial statements, such as the effects of refinancing and noncompliance with debt covenants.</ElementDefenition><ElementReferences>Reference 1: http://www.xbrl.org/2003/role/presentationRef

 -Publisher FASB

 -Name Accounting Standards Codification

 -Topic 505

 -SubTopic 10

 -Section 50

 -Paragraph 3

 -URI http://asc.fasb.org/extlink&amp;oid=6928386&amp;loc=d3e21475-112644



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

 -Publisher SEC

 -Name Regulation S-X (SX)

 -Number 210

 -Section 02

 -Paragraph 19, 20, 22

 -Article 5



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

 -Publisher FASB

 -Name Statement of Financial Accounting Standard (FAS)

 -Number 129

 -Paragraph 2, 4

 -LegacyDoc This reference is SUPERSEDED by the Accounting Standards Codification effective for interim and annual periods ending after September 15, 2009.  This reference is included to help users transition from the previous accounting hierarchy and will be removed from future versions of this taxonomy.



Reference 4: 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.19,20,22)

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



</ElementReferences><IsTotalLabel>false</IsTotalLabel><UnitID>0</UnitID><Label>Repurchase agreement</Label></Row></Rows><Footnotes /><IsEquityReport>false</IsEquityReport><ReportName>Repurchase agreement</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.altisourceamc.com/role/RepurchaseAgreement</RoleURI><NumberOfCols>1</NumberOfCols><NumberOfRows>2</NumberOfRows></InstanceReport>
